From 71b48a68a15f69ab9b8706970ec603469215fe39 Mon Sep 17 00:00:00 2001 From: sriramsv Date: Tue, 27 Dec 2022 15:05:38 -0800 Subject: [PATCH 001/204] Add Tasker command search and edit sunrise widget --- community/public-ip-search.lua | 1 + community/sunrise-sunset-widget.lua | 26 ++++++++++++++++++++++---- community/tasker-command-search.lua | 24 ++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 community/tasker-command-search.lua diff --git a/community/public-ip-search.lua b/community/public-ip-search.lua index febd5b2..e4a0338 100644 --- a/community/public-ip-search.lua +++ b/community/public-ip-search.lua @@ -4,6 +4,7 @@ -- type = "search" -- author = "Sriram SV" -- version = "1.0" +-- prefix = "ip" local md_color = require "md_colors" local blue = md_colors.blue_500 diff --git a/community/sunrise-sunset-widget.lua b/community/sunrise-sunset-widget.lua index 5f3129a..d379c64 100644 --- a/community/sunrise-sunset-widget.lua +++ b/community/sunrise-sunset-widget.lua @@ -8,12 +8,30 @@ local json = require "json" local date = require "date" -function on_alarm() - local location=system:location() - url="https://api.sunrise-sunset.org/json?lat="..location[1].."&lng="..location[2].."&date=today&formatted=1" - http:get(url) + +global_loc = {} + +function on_resume() + if global_loc ~=nil then + ui:show_text("Tap to request location") + end end +function on_click() + system:request_location() + ui:show_text("Loading...") +end + +function on_location_result(location) + if location ~= nil then + ui:show_text(location[1].." "..location[2]) + global_loc = location + url="https://api.sunrise-sunset.org/json?lat="..location[1].."&lng="..location[2].."&date=today&formatted=1" + http:get(url) + else + ui:show_text("Error") + end +end function on_network_result(result) local t = json.decode(result) diff --git a/community/tasker-command-search.lua b/community/tasker-command-search.lua new file mode 100644 index 0000000..31c3cf5 --- /dev/null +++ b/community/tasker-command-search.lua @@ -0,0 +1,24 @@ +-- name = "Tasker Command Search" +-- description = "Sends tasker command from search bar" +-- data_source = "tasker" +-- type = "search" +-- author = "Sriram SV" +-- version = "1.0" +-- prefix = "tasker | Tasker | command" + +local md_color = require "md_colors" +local orange = md_colors.orange_500 + +text_from = "" +text_to = "" + +function on_search(input) + text_from = input + text_to = "" + search:show({input},{orange}) +end + +function on_click(idx) + text_from=text_from:replace(" ", "=:=") + tasker:send_command(text_from) +end -- 2.43.0 From ab059d23021aa196b0343cd585481eba0255eb44 Mon Sep 17 00:00:00 2001 From: sriramsv Date: Tue, 27 Dec 2022 18:51:16 -0800 Subject: [PATCH 002/204] Fix Sunrise sunset bug --- community/sunrise-sunset-widget.lua | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/community/sunrise-sunset-widget.lua b/community/sunrise-sunset-widget.lua index d379c64..7069634 100644 --- a/community/sunrise-sunset-widget.lua +++ b/community/sunrise-sunset-widget.lua @@ -9,11 +9,14 @@ local json = require "json" local date = require "date" -global_loc = {} - +l1 = {} +l2 = {} function on_resume() - if global_loc ~=nil then + l2=settings:get_kv() + if next(l2) == nil then ui:show_text("Tap to request location") + else + get_sunrise_sunset(l2) end end @@ -24,15 +27,24 @@ end function on_location_result(location) if location ~= nil then - ui:show_text(location[1].." "..location[2]) - global_loc = location - url="https://api.sunrise-sunset.org/json?lat="..location[1].."&lng="..location[2].."&date=today&formatted=1" - http:get(url) + l1.lat = location[1] + l1.long = location[2] + settings:set_kv(l1) + get_sunrise_sunset(l1) else ui:show_text("Error") end end +function get_sunrise_sunset(location) + if location~=nil then + url="https://api.sunrise-sunset.org/json?lat="..location.lat.."&lng="..location.long.."&date=today&formatted=1" + http:get(url) + else + ui:show_text("Location Empty") + end +end + function on_network_result(result) local t = json.decode(result) local table = { -- 2.43.0 From dcbdb6bdb72ee94fc97b77414495905dbea00efe Mon Sep 17 00:00:00 2001 From: zobnin Date: Wed, 28 Dec 2022 09:11:27 +0300 Subject: [PATCH 003/204] Delete public-ip-search.lua --- community/public-ip-search.lua | 37 ---------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 community/public-ip-search.lua diff --git a/community/public-ip-search.lua b/community/public-ip-search.lua deleted file mode 100644 index e4a0338..0000000 --- a/community/public-ip-search.lua +++ /dev/null @@ -1,37 +0,0 @@ --- name = "Public IP" --- description = "Shows your public IP in the search bar" --- data_source = "ipify.org" --- type = "search" --- author = "Sriram SV" --- version = "1.0" --- prefix = "ip" - -local md_color = require "md_colors" -local blue = md_colors.blue_500 -local red = md_colors.red_500 - -local ip = "" -function on_search(input) - if input:lower():find("^ip$") then - get_ip() - end -end - -function on_click() - system:copy_to_clipboard(ip) -end - -function get_ip() - http:get("https://api.ipify.org") -end - -function on_network_result(result,code) - if code >= 200 and code < 300 then - ip = result - search:show({result},{blue}) - else - search:show({"Server Error"},{red}) - end -end - - -- 2.43.0 From b0287dcea76bebf4e7811d0b1d284c73ea487294 Mon Sep 17 00:00:00 2001 From: sriramsv Date: Tue, 27 Dec 2022 23:44:31 -0800 Subject: [PATCH 004/204] Tasker Command Search --- community/tasker-command-search.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 community/tasker-command-search.lua diff --git a/community/tasker-command-search.lua b/community/tasker-command-search.lua new file mode 100644 index 0000000..93cc135 --- /dev/null +++ b/community/tasker-command-search.lua @@ -0,0 +1,25 @@ +-- name = "Tasker Command Search" +-- description = "Sends tasker command from search bar" +-- data_source = "tasker" +-- type = "search" +-- author = "Sriram SV" +-- version = "1.0" +-- prefix = "tasker | Tasker | command" + +local md_color = require "md_colors" +local orange = md_colors.orange_500 + +text_from = "" +text_to = "" + +function on_search(input) + text_from = input + text_to = "" + search:show({input},{orange}) +end + +function on_click(idx) + text_from = string.lower(text_from) + text_from=text_from:replace(" ", "=:=") + tasker:send_command(text_from) +end \ No newline at end of file -- 2.43.0 From e76d17b5dea5f36bc76a162a0b7bb3672593c198 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 29 Dec 2022 11:45:20 +0400 Subject: [PATCH 005/204] add new APIs --- README.md | 7 +++++-- samples/command-receiver-search.lua | 6 ++++++ samples/location-widget.lua | 2 +- samples/location-widget2.lua | 16 ++++++++++++++++ samples/msg-sender.lua | 8 ++++---- 5 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 samples/command-receiver-search.lua create mode 100644 samples/location-widget2.lua diff --git a/README.md b/README.md index b6db242..146399f 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,8 @@ The type of script is determined by the line (meta tag) at the beginning of the * 4.5.3 - removed get_ prefixes where they are not needed while maintaining backward compatibility; * 4.5.5 - added `on_action` callback and `calendar:add_event` function; * 4.5.6 - `aio:active_widgets()` now returns also widget `label`, added `checks` module; -* 4.5.7 - added "fold" and "unfold" actions to `on_action` callback. +* 4.5.7 - added "fold" and "unfold" actions to the `on_action` callback; +* 4.6.0 - added `system:request_location()` and `tasker:send_command()` functions. # Widget scripts @@ -194,6 +195,7 @@ When you click on any menu item, the collback `on_context_menu_click(idx)` will * `system:exec(string)` - executes a shell command; * `system:su(string)` - executes a shell command as root; * `system:location()` - returns the location in the table with two values (location request is NOT executed, the value previously saved by the system is used); +* `system:request_location()` - queries the current location and returns it to the `on_location_result` callback; * `system:to_clipboard(string)` - copies the string to the clipboard; * `system:clipboard()` - returns a string from the clipboard: * `system:vibrate(milliseconds)` - vibrate; @@ -458,7 +460,8 @@ _Avaialble from: 4.4.4_ * `tasker:tasks([project])` - returns a list of all the tasks in the Tasker, the second optional argument is the project for which you want to get the tasks (returns nil if Tasker is not installed or enabled); * `tasker:projects()` - returns all Tasker projects (returns nil if Tasker is not installed or enabled); * `tasker:run_task(name, [args])` - executes the task in the Tasker, the second optional argument is a table of variables passed to the task in the format `{ "name" = "value" }`; -* `tasker:run_own_task(commands)` - constructs and performs the task on the fly. +* `tasker:run_own_task(commands)` - constructs and performs the task on the fly; +* `tasker:send_command(command)` - sends [tasker command](https://tasker.joaoapps.com/commandsystem.html). The `run_own_task` function takes as a parameter a list of Tasker commands in the following format: diff --git a/samples/command-receiver-search.lua b/samples/command-receiver-search.lua new file mode 100644 index 0000000..3bf401b --- /dev/null +++ b/samples/command-receiver-search.lua @@ -0,0 +1,6 @@ +-- name = "Command receiver" +-- type = "search" + +function on_command(value) + search:show{value} +end diff --git a/samples/location-widget.lua b/samples/location-widget.lua index c10a4b2..e0f395d 100644 --- a/samples/location-widget.lua +++ b/samples/location-widget.lua @@ -1,4 +1,4 @@ function on_resume() - local location = system:get_location() + local location = system:location() ui:show_text(location[1].." "..location[2]) end diff --git a/samples/location-widget2.lua b/samples/location-widget2.lua new file mode 100644 index 0000000..5cec26c --- /dev/null +++ b/samples/location-widget2.lua @@ -0,0 +1,16 @@ +function on_resume() + ui:show_text("Tap to request location") +end + +function on_click() + system:request_location() + ui:show_text("Loading...") +end + +function on_location_result(location) + if location ~= nil then + ui:show_text(location[1].." "..location[2]) + else + ui:show_text("Error") + end +end diff --git a/samples/msg-sender.lua b/samples/msg-sender.lua index a318594..ba29437 100644 --- a/samples/msg-sender.lua +++ b/samples/msg-sender.lua @@ -1,8 +1,8 @@ function on_resume() ui:show_lines{ - "send text", - "send 123", - "send table", + "send text to msg-receiver.lua script", + "send 123 to all", + "send table to all", } end @@ -10,7 +10,7 @@ function on_click(idx) if idx == 1 then aio:send_message("text", "msg-receiver.lua") elseif idx == 2 then - aio:send_message(1) + aio:send_message(123) else aio:send_message{ "one", "two", "three" } end -- 2.43.0 From 67a3b2444a3ad5e1a9b9c8602b56113334dec14b Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 28 Jan 2023 16:10:38 +0400 Subject: [PATCH 006/204] startpage search script should show results on the top --- community/starpage-search.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/community/starpage-search.lua b/community/starpage-search.lua index 4882ac1..e158ae2 100644 --- a/community/starpage-search.lua +++ b/community/starpage-search.lua @@ -33,7 +33,7 @@ function show(result) table.insert(results, v.text) end - search:show(results) + search:show_top(results) end function on_click(idx) -- 2.43.0 From 45653bdcaa23d3d70c3139b14176a082089b3dc9 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 31 Jan 2023 10:45:28 +0400 Subject: [PATCH 007/204] add unknown statuses handling to uptime robot script --- main/uptimerobot-widget.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main/uptimerobot-widget.lua b/main/uptimerobot-widget.lua index 68de1c1..cbfbc14 100644 --- a/main/uptimerobot-widget.lua +++ b/main/uptimerobot-widget.lua @@ -62,7 +62,10 @@ function format_status(status) local statuses = { "not checked", "up", "error", "error", "error", "error", "error", "seems down", "down" } local status_colors = { "yellow_500", "green_500", "red_500", "red_500", "red_500", "red_500", "red_500", "orange_500", "red_500" } - return ""..statuses[status].."" + local status_str = statuses[status] or "unknown" + local status_color = md_colors[status_colors[status]] or md_colors["grey_500"] + + return ""..status_str.."" end function table_to_tables(tab, num) -- 2.43.0 From 003b8d7cbb97ad2b114190d66df7135ec973312f Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 31 Jan 2023 10:59:42 +0400 Subject: [PATCH 008/204] move todoist widget out of main repo --- {main => community}/todoist-widget.lua | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {main => community}/todoist-widget.lua (100%) diff --git a/main/todoist-widget.lua b/community/todoist-widget.lua similarity index 100% rename from main/todoist-widget.lua rename to community/todoist-widget.lua -- 2.43.0 From 4dc9f05907ca09ed6d99615b8f882e67f6e76991 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 31 Jan 2023 11:01:33 +0400 Subject: [PATCH 009/204] update scripts --- scripts.index | 1 - scripts.md5 | 2 +- scripts.zip | Bin 24813 -> 20227 bytes 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts.index b/scripts.index index c01fc45..da3f458 100644 --- a/scripts.index +++ b/scripts.index @@ -10,7 +10,6 @@ public-ip-widget.lua quotes-widget.lua shell-widget.lua sys-info-widget.lua -todoist-widget.lua unit-converter.lua uptimerobot-widget.lua widgets-on-off.lua diff --git a/scripts.md5 b/scripts.md5 index de1043e..1aa7fdb 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -647f5e2914cc0e3ace23caa6242bf812 +76a6d46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ri|$4CLDTZ%el3KbBe}l>xE4P zJP_Yeo?y7ImnwF7^&m-M(OIiDtYJre?1MVsl{vg~06OWQhoAE2(>yRj#v5C(I3`_@ zYE&>X6%k3KEqksglDxwx5_c#MbxNbHi}Uun{S?OK7rv+K*%n3}i-aY&iAD^OH)a;x zcUew;H{<_EV0}_2?|}+c<5apc;oBJVJWdNJusT`*>~t}c3lM@N;8)|7~~fh zcL}+LXLbR}AGyBs@_!LOTM(zKsJ#*}?#nEc+@tQOOCy)y3oIR-)BJJtStd$Ms;}YW zk$+!F$kxs4&l~noemln|Zkz+%6$0oXl8%}U=V`t{=Jp`+dqy&LQ$Y(1u?h|8$F*AB zz6Ewmza)ZATn^i;RH-pu_ggG$ zN=))#O*B>?s0fdq!?OA~Uo23w78;zfE>{91M?980Kf%|`%@arbn*Z_u>b%#l#lH%mM!9I!TKxg zg@62mx#D8V|FCSxlK{fMsT&2ke<@i|^}p1yG73xf{}Nl8KXm{Av_DZ8D#QTzfB7xe zUw#W;QKN_VYBHj42*S5CC7J(6gTMsR$003U_f3E#s$?+4} -- 2.43.0 From 75057f8c422ca3c5675fcdb2210f86e5463099aa Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 23 Feb 2023 13:20:34 +0400 Subject: [PATCH 010/204] Add new APIs --- README.md | 45 ++++++++++++++++++++++++++++++++----- samples/build_ui_sample.lua | 19 ++++++++++++++++ samples/search-test.lua | 2 +- samples/search-test2.lua | 2 +- samples/search-test3.lua | 19 ++++++++++++++++ samples/search-test4.lua | 20 +++++++++++++++++ samples/search-test5.lua | 20 +++++++++++++++++ 7 files changed, 119 insertions(+), 8 deletions(-) create mode 100644 samples/build_ui_sample.lua create mode 100644 samples/search-test3.lua create mode 100644 samples/search-test4.lua create mode 100644 samples/search-test5.lua diff --git a/README.md b/README.md index 146399f..65bf1f0 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,8 @@ The type of script is determined by the line (meta tag) at the beginning of the * 4.5.5 - added `on_action` callback and `calendar:add_event` function; * 4.5.6 - `aio:active_widgets()` now returns also widget `label`, added `checks` module; * 4.5.7 - added "fold" and "unfold" actions to the `on_action` callback; -* 4.6.0 - added `system:request_location()` and `tasker:send_command()` functions. +* 4.6.0 - added `system:request_location()` and `tasker:send_command()` functions; +* 4.7.0 - added `ui:build()` and functions to display search results in different formats. # Widget scripts @@ -55,10 +56,10 @@ Unlike widget scripts, search scripts are launched only when you open the search The search script can use two functions to display search results: -* `search:show(strings, [colors])` - shows results BELOW all other results; -* `search:show_top(strings, [colors])` - shows results BEFORE all other results. - -Both functions take a table with search results strings as the first argument. Second optional parameter: table with colors of results in format `#XXXXXX`. +* `search:show_buttons(names, [colors], [top])` - show buttons in the search results, the first parameter is table of button names, second - table of button colors in format `#XXXXXX`, `top` - whether the results need to be shown at the top (false by default); +* `search:show_lines(lines, [colors], [top])` - show text lines in the search results; +* `search:show_progress(names, progresses, [colors], [top])` - show progress bars in the search results, the first parameter is a table of names, the second is a table of progress bars (from 1 to 100); +* `search:show_chart(points, format, [title], [show_grid], [top])` - show chart in the search results, parameters are analogous to `ui:show_chart()`. When user click on a result, one of the following functions will be executed: @@ -114,7 +115,7 @@ First line
Second line You can also use Markdown markup. To do this, add the prefix `%%mkd%%` to the beginning of the line. Or you can disable the formatting completely with the prefix `%%txt%%`. -The `ui:show_buttons()` function supports Fontawesome icons. Simply specify `fa:icon_name` as the button name, for example: `fa:play`. +The `ui:show_buttons()` function supports Fontawesome icons. Simply specify `fa:icon_name` as the button name, for example: `fa:play`. (Note: AIO only supports icons up to Fontawesome 5.12.) ## Dialogs @@ -189,6 +190,38 @@ Here `share`, `copy` and `trash` are the names of the icons, which can be found When you click on any menu item, the collback `on_context_menu_click(idx)` will be called, where `idx` is the index of the menu item. +## Build meta-widget + +_Avaialble from: 4.7.0_ + +* `ui:build(table)` - constructs a widget from pieces of other AIO widgets. + +The function takes a command table of this format as a parameter: + +``` +`battery` - battery progress bar; +`ram` - ram progress bar; +`nand` - nand progress bar; +`traffic` - traffic progress bar; +`screen` - screen time progress bar; +`alarm` - next alarm info; +`notes [NUM]` - last NUM notes; +`tasks [NUM]` - last NUM tasks; +`calendar [NUM]` - last NUM calendar events; +`exchage [NUM] [FROM] [TO]` - exchange rate FROM currency TO currency; +`player` - player controls; +`health` - health data; +`weather [NUM]` - weather forecast for NUM days; +`bitcoin` - bitcoin rate chart; +`worldclock [TIME_ZONE]` - time in the given TIME_ZONE; +`notify [NUM]` - last NUM notifications; +`dialogs [NUM]` - last NUM dialogs; +`text [TEXT]` - just shows TEXT; +`space [NUM]` - NUM of spaces. +``` + +[Sample](samples/build_ui_sample.lua). + ## System * `system:open_browser(url)` - opens the specified URL in a browser or application that can handle this type of URL; diff --git a/samples/build_ui_sample.lua b/samples/build_ui_sample.lua new file mode 100644 index 0000000..49fd0c1 --- /dev/null +++ b/samples/build_ui_sample.lua @@ -0,0 +1,19 @@ +function on_resume() + ui:build{ + "text This is a sample", + "space 2", + "text Battery level", + "space", + "battery", + "space 2", + "text Notes", + "space", + "notes 2", + "space 2", + "text Exchange rates", + "exchange 10 usd amd", + "space 2", + "text Timezones", + "worldclock new_york kiev bangkok", + } +end diff --git a/samples/search-test.lua b/samples/search-test.lua index 379ea91..12c2a51 100644 --- a/samples/search-test.lua +++ b/samples/search-test.lua @@ -4,7 +4,7 @@ local table = {} function on_search(input) - search:show({ input.." 1", input.." 2" }) + search:show_buttons({ input.." 1", input.." 2" }) end function on_click(idx) diff --git a/samples/search-test2.lua b/samples/search-test2.lua index 9824346..acace51 100644 --- a/samples/search-test2.lua +++ b/samples/search-test2.lua @@ -7,7 +7,7 @@ function on_search() local texts = { "text1", "text2", "text3" } local colors = { md_colors.purple_400, md_colors.purple_600, md_colors.purple_800 } - search:show(texts, colors) + search:show_buttons(texts, colors) end function on_click(idx) diff --git a/samples/search-test3.lua b/samples/search-test3.lua new file mode 100644 index 0000000..03c4c2f --- /dev/null +++ b/samples/search-test3.lua @@ -0,0 +1,19 @@ +-- name = "Script #3" +-- type = "search" + +md_colors = require("md_colors") + +function on_search() + local texts = { "Line one", "Line two", "Line three" } + local colors = { md_colors.purple_400, md_colors.purple_600, md_colors.purple_800 } + + search:show_lines(texts, colors) +end + +function on_click(idx) + if idx == 1 then + system:vibrate(100) + else + system:vibrate(300) + end +end diff --git a/samples/search-test4.lua b/samples/search-test4.lua new file mode 100644 index 0000000..7d32b5f --- /dev/null +++ b/samples/search-test4.lua @@ -0,0 +1,20 @@ +-- name = "Script #4" +-- type = "search" + +md_colors = require("md_colors") + +function on_search() + local texts = { "progress 1", "progress 2", "progress 3" } + local progresses = { 10, 50, 90 } + local colors = { md_colors.purple_400, md_colors.purple_600, md_colors.purple_800 } + + search:show_progress(texts, progresses, colors) +end + +function on_click(idx) + if idx == 1 then + system:vibrate(100) + else + system:vibrate(300) + end +end diff --git a/samples/search-test5.lua b/samples/search-test5.lua new file mode 100644 index 0000000..58969c9 --- /dev/null +++ b/samples/search-test5.lua @@ -0,0 +1,20 @@ +-- name = "Script #5" +-- type = "search" + +function on_search() + local points = { + { 1628501740654, 123456789 }, + { 1628503740654, 300000000 }, + { 1628505740654, 987654321 }, + } + + search:show_chart(points, "x:date y:number") +end + +function on_click(idx) + if idx == 1 then + system:vibrate(100) + else + system:vibrate(300) + end +end -- 2.43.0 From 57e0c5c7907e425b7f5df06d968a539f1ef8a01a Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 23 Feb 2023 13:23:39 +0400 Subject: [PATCH 011/204] Add new APIs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 65bf1f0..23aabbb 100644 --- a/README.md +++ b/README.md @@ -190,7 +190,7 @@ Here `share`, `copy` and `trash` are the names of the icons, which can be found When you click on any menu item, the collback `on_context_menu_click(idx)` will be called, where `idx` is the index of the menu item. -## Build meta-widget +## Meta widgets _Avaialble from: 4.7.0_ -- 2.43.0 From cadc5aace79283558cb29cf5490bff3e83463804 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 6 Mar 2023 18:55:35 +0400 Subject: [PATCH 012/204] add country search script --- community/country-search.lua | 2748 ++++++++++++++++++++++++++++++++++ 1 file changed, 2748 insertions(+) create mode 100644 community/country-search.lua diff --git a/community/country-search.lua b/community/country-search.lua new file mode 100644 index 0000000..0622e02 --- /dev/null +++ b/community/country-search.lua @@ -0,0 +1,2748 @@ +-- name = "Country" +-- description = "Search country by code or name" +-- type = "search" +-- version = "1.0" +-- author = "Evgeny Zobnin (zobnin@gmail.com)" + +--- Original code: https://dev.fandom.com/wiki/Global_Lua_Modules/Country + +function on_search(str) + if str == nil then return end + + if str:len() == 2 then + result = getCountryData(str, "name") + else + result = getCountryCode(str, true) + end + + if result ~= nil then + search:show_buttons{ result } + end +end + +function getCountryData(code, info) + if info and code then + -- if the code doesn't exist try looking for a country name + if not countryData[code] then + code = getCountryCode(code) + end + return (countryData[code] or {})[info] + end +end + +function getCountryCode(name, bCloseMatch) + name = name:lower() + + for sCode, sData in pairs(countryData) do + if sData.name:lower() == name or bCloseMatch and sData.name:match(name) then + return sCode:lower() + end + end +end + +countryData = { + ad = { + ["alpha-2"] = "AD", + ["alpha-3"] = "AND", + ["country-code"] = "020", + ["iso_3166-2"] = "ISO 3166-2:AD", + name = "Andorra", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Southern Europe", + ["sub-region-code"] = "039" + }, + ae = { + ["alpha-2"] = "AE", + ["alpha-3"] = "ARE", + ["country-code"] = "784", + ["iso_3166-2"] = "ISO 3166-2:AE", + name = "United Arab Emirates", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Western Asia", + ["sub-region-code"] = "145" + }, + af = { + ["alpha-2"] = "AF", + ["alpha-3"] = "AFG", + ["country-code"] = "004", + ["iso_3166-2"] = "ISO 3166-2:AF", + name = "Afghanistan", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Southern Asia", + ["sub-region-code"] = "034" + }, + ag = { + ["alpha-2"] = "AG", + ["alpha-3"] = "ATG", + ["country-code"] = "028", + ["iso_3166-2"] = "ISO 3166-2:AG", + name = "Antigua and Barbuda", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + ai = { + ["alpha-2"] = "AI", + ["alpha-3"] = "AIA", + ["country-code"] = "660", + ["iso_3166-2"] = "ISO 3166-2:AI", + name = "Anguilla", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + al = { + ["alpha-2"] = "AL", + ["alpha-3"] = "ALB", + ["country-code"] = "008", + ["iso_3166-2"] = "ISO 3166-2:AL", + name = "Albania", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Southern Europe", + ["sub-region-code"] = "039" + }, + am = { + ["alpha-2"] = "AM", + ["alpha-3"] = "ARM", + ["country-code"] = "051", + ["iso_3166-2"] = "ISO 3166-2:AM", + name = "Armenia", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Western Asia", + ["sub-region-code"] = "145" + }, + ao = { + ["alpha-2"] = "AO", + ["alpha-3"] = "AGO", + ["country-code"] = "024", + ["iso_3166-2"] = "ISO 3166-2:AO", + name = "Angola", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Middle Africa", + ["sub-region-code"] = "017" + }, + aq = { + ["alpha-2"] = "AQ", + ["alpha-3"] = "ATA", + ["country-code"] = "010", + ["iso_3166-2"] = "ISO 3166-2:AQ", + name = "Antarctica" + }, + ar = { + ["alpha-2"] = "AR", + ["alpha-3"] = "ARG", + ["country-code"] = "032", + ["iso_3166-2"] = "ISO 3166-2:AR", + name = "Argentina", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "South America", + ["sub-region-code"] = "005" + }, + as = { + ["alpha-2"] = "AS", + ["alpha-3"] = "ASM", + ["country-code"] = "016", + ["iso_3166-2"] = "ISO 3166-2:AS", + name = "American Samoa", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Polynesia", + ["sub-region-code"] = "061" + }, + at = { + ["alpha-2"] = "AT", + ["alpha-3"] = "AUT", + ["country-code"] = "040", + ["iso_3166-2"] = "ISO 3166-2:AT", + name = "Austria", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Western Europe", + ["sub-region-code"] = "155" + }, + au = { + ["alpha-2"] = "AU", + ["alpha-3"] = "AUS", + ["country-code"] = "036", + ["iso_3166-2"] = "ISO 3166-2:AU", + name = "Australia", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Australia and New Zealand", + ["sub-region-code"] = "053" + }, + aw = { + ["alpha-2"] = "AW", + ["alpha-3"] = "ABW", + ["country-code"] = "533", + ["iso_3166-2"] = "ISO 3166-2:AW", + name = "Aruba", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + ax = { + ["alpha-2"] = "AX", + ["alpha-3"] = "ALA", + ["country-code"] = "248", + ["iso_3166-2"] = "ISO 3166-2:AX", + name = "Åland Islands", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Northern Europe", + ["sub-region-code"] = "154" + }, + az = { + ["alpha-2"] = "AZ", + ["alpha-3"] = "AZE", + ["country-code"] = "031", + ["iso_3166-2"] = "ISO 3166-2:AZ", + name = "Azerbaijan", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Western Asia", + ["sub-region-code"] = "145" + }, + ba = { + ["alpha-2"] = "BA", + ["alpha-3"] = "BIH", + ["country-code"] = "070", + ["iso_3166-2"] = "ISO 3166-2:BA", + name = "Bosnia and Herzegovina", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Southern Europe", + ["sub-region-code"] = "039" + }, + bb = { + ["alpha-2"] = "BB", + ["alpha-3"] = "BRB", + ["country-code"] = "052", + ["iso_3166-2"] = "ISO 3166-2:BB", + name = "Barbados", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + bd = { + ["alpha-2"] = "BD", + ["alpha-3"] = "BGD", + ["country-code"] = "050", + ["iso_3166-2"] = "ISO 3166-2:BD", + name = "Bangladesh", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Southern Asia", + ["sub-region-code"] = "034" + }, + be = { + ["alpha-2"] = "BE", + ["alpha-3"] = "BEL", + ["country-code"] = "056", + ["iso_3166-2"] = "ISO 3166-2:BE", + name = "Belgium", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Western Europe", + ["sub-region-code"] = "155" + }, + bf = { + ["alpha-2"] = "BF", + ["alpha-3"] = "BFA", + ["country-code"] = "854", + ["iso_3166-2"] = "ISO 3166-2:BF", + name = "Burkina Faso", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Western Africa", + ["sub-region-code"] = "011" + }, + bg = { + ["alpha-2"] = "BG", + ["alpha-3"] = "BGR", + ["country-code"] = "100", + ["iso_3166-2"] = "ISO 3166-2:BG", + name = "Bulgaria", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Eastern Europe", + ["sub-region-code"] = "151" + }, + bh = { + ["alpha-2"] = "BH", + ["alpha-3"] = "BHR", + ["country-code"] = "048", + ["iso_3166-2"] = "ISO 3166-2:BH", + name = "Bahrain", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Western Asia", + ["sub-region-code"] = "145" + }, + bi = { + ["alpha-2"] = "BI", + ["alpha-3"] = "BDI", + ["country-code"] = "108", + ["iso_3166-2"] = "ISO 3166-2:BI", + name = "Burundi", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Eastern Africa", + ["sub-region-code"] = "014" + }, + bj = { + ["alpha-2"] = "BJ", + ["alpha-3"] = "BEN", + ["country-code"] = "204", + ["iso_3166-2"] = "ISO 3166-2:BJ", + name = "Benin", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Western Africa", + ["sub-region-code"] = "011" + }, + bl = { + ["alpha-2"] = "BL", + ["alpha-3"] = "BLM", + ["country-code"] = "652", + ["iso_3166-2"] = "ISO 3166-2:BL", + name = "Saint Barthélemy", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + bm = { + ["alpha-2"] = "BM", + ["alpha-3"] = "BMU", + ["country-code"] = "060", + ["iso_3166-2"] = "ISO 3166-2:BM", + name = "Bermuda", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Northern America", + ["sub-region-code"] = "021" + }, + bn = { + ["alpha-2"] = "BN", + ["alpha-3"] = "BRN", + ["country-code"] = "096", + ["iso_3166-2"] = "ISO 3166-2:BN", + name = "Brunei Darussalam", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "South-Eastern Asia", + ["sub-region-code"] = "035" + }, + bo = { + ["alpha-2"] = "BO", + ["alpha-3"] = "BOL", + ["country-code"] = "068", + ["iso_3166-2"] = "ISO 3166-2:BO", + name = "Bolivia (Plurinational State of)", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "South America", + ["sub-region-code"] = "005" + }, + bq = { + ["alpha-2"] = "BQ", + ["alpha-3"] = "BES", + ["country-code"] = "535", + ["iso_3166-2"] = "ISO 3166-2:BQ", + name = "Bonaire, Sint Eustatius and Saba", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + br = { + ["alpha-2"] = "BR", + ["alpha-3"] = "BRA", + ["country-code"] = "076", + ["iso_3166-2"] = "ISO 3166-2:BR", + name = "Brazil", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "South America", + ["sub-region-code"] = "005" + }, + bs = { + ["alpha-2"] = "BS", + ["alpha-3"] = "BHS", + ["country-code"] = "044", + ["iso_3166-2"] = "ISO 3166-2:BS", + name = "Bahamas", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + bt = { + ["alpha-2"] = "BT", + ["alpha-3"] = "BTN", + ["country-code"] = "064", + ["iso_3166-2"] = "ISO 3166-2:BT", + name = "Bhutan", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Southern Asia", + ["sub-region-code"] = "034" + }, + bv = { + ["alpha-2"] = "BV", + ["alpha-3"] = "BVT", + ["country-code"] = "074", + ["iso_3166-2"] = "ISO 3166-2:BV", + name = "Bouvet Island" + }, + bw = { + ["alpha-2"] = "BW", + ["alpha-3"] = "BWA", + ["country-code"] = "072", + ["iso_3166-2"] = "ISO 3166-2:BW", + name = "Botswana", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Southern Africa", + ["sub-region-code"] = "018" + }, + by = { + ["alpha-2"] = "BY", + ["alpha-3"] = "BLR", + ["country-code"] = "112", + ["iso_3166-2"] = "ISO 3166-2:BY", + name = "Belarus", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Eastern Europe", + ["sub-region-code"] = "151" + }, + bz = { + ["alpha-2"] = "BZ", + ["alpha-3"] = "BLZ", + ["country-code"] = "084", + ["iso_3166-2"] = "ISO 3166-2:BZ", + name = "Belize", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Central America", + ["sub-region-code"] = "013" + }, + ca = { + ["alpha-2"] = "CA", + ["alpha-3"] = "CAN", + ["country-code"] = "124", + ["iso_3166-2"] = "ISO 3166-2:CA", + name = "Canada", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Northern America", + ["sub-region-code"] = "021" + }, + cc = { + ["alpha-2"] = "CC", + ["alpha-3"] = "CCK", + ["country-code"] = "166", + ["iso_3166-2"] = "ISO 3166-2:CC", + name = "Cocos (Keeling) Islands" + }, + cd = { + ["alpha-2"] = "CD", + ["alpha-3"] = "COD", + ["country-code"] = "180", + ["iso_3166-2"] = "ISO 3166-2:CD", + name = "Congo (Democratic Republic of the)", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Middle Africa", + ["sub-region-code"] = "017" + }, + cf = { + ["alpha-2"] = "CF", + ["alpha-3"] = "CAF", + ["country-code"] = "140", + ["iso_3166-2"] = "ISO 3166-2:CF", + name = "Central African Republic", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Middle Africa", + ["sub-region-code"] = "017" + }, + cg = { + ["alpha-2"] = "CG", + ["alpha-3"] = "COG", + ["country-code"] = "178", + ["iso_3166-2"] = "ISO 3166-2:CG", + name = "Congo", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Middle Africa", + ["sub-region-code"] = "017" + }, + ch = { + ["alpha-2"] = "CH", + ["alpha-3"] = "CHE", + ["country-code"] = "756", + ["iso_3166-2"] = "ISO 3166-2:CH", + name = "Switzerland", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Western Europe", + ["sub-region-code"] = "155" + }, + ci = { + ["alpha-2"] = "CI", + ["alpha-3"] = "CIV", + ["country-code"] = "384", + ["iso_3166-2"] = "ISO 3166-2:CI", + name = "Côte d'Ivoire", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Western Africa", + ["sub-region-code"] = "011" + }, + ck = { + ["alpha-2"] = "CK", + ["alpha-3"] = "COK", + ["country-code"] = "184", + ["iso_3166-2"] = "ISO 3166-2:CK", + name = "Cook Islands", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Polynesia", + ["sub-region-code"] = "061" + }, + cl = { + ["alpha-2"] = "CL", + ["alpha-3"] = "CHL", + ["country-code"] = "152", + ["iso_3166-2"] = "ISO 3166-2:CL", + name = "Chile", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "South America", + ["sub-region-code"] = "005" + }, + cm = { + ["alpha-2"] = "CM", + ["alpha-3"] = "CMR", + ["country-code"] = "120", + ["iso_3166-2"] = "ISO 3166-2:CM", + name = "Cameroon", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Middle Africa", + ["sub-region-code"] = "017" + }, + cn = { + ["alpha-2"] = "CN", + ["alpha-3"] = "CHN", + ["country-code"] = "156", + ["iso_3166-2"] = "ISO 3166-2:CN", + name = "China", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Eastern Asia", + ["sub-region-code"] = "030" + }, + co = { + ["alpha-2"] = "CO", + ["alpha-3"] = "COL", + ["country-code"] = "170", + ["iso_3166-2"] = "ISO 3166-2:CO", + name = "Colombia", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "South America", + ["sub-region-code"] = "005" + }, + cr = { + ["alpha-2"] = "CR", + ["alpha-3"] = "CRI", + ["country-code"] = "188", + ["iso_3166-2"] = "ISO 3166-2:CR", + name = "Costa Rica", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Central America", + ["sub-region-code"] = "013" + }, + cu = { + ["alpha-2"] = "CU", + ["alpha-3"] = "CUB", + ["country-code"] = "192", + ["iso_3166-2"] = "ISO 3166-2:CU", + name = "Cuba", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + cv = { + ["alpha-2"] = "CV", + ["alpha-3"] = "CPV", + ["country-code"] = "132", + ["iso_3166-2"] = "ISO 3166-2:CV", + name = "Cabo Verde", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Western Africa", + ["sub-region-code"] = "011" + }, + cw = { + ["alpha-2"] = "CW", + ["alpha-3"] = "CUW", + ["country-code"] = "531", + ["iso_3166-2"] = "ISO 3166-2:CW", + name = "Curaçao", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + cx = { + ["alpha-2"] = "CX", + ["alpha-3"] = "CXR", + ["country-code"] = "162", + ["iso_3166-2"] = "ISO 3166-2:CX", + name = "Christmas Island" + }, + cy = { + ["alpha-2"] = "CY", + ["alpha-3"] = "CYP", + ["country-code"] = "196", + ["iso_3166-2"] = "ISO 3166-2:CY", + name = "Cyprus", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Western Asia", + ["sub-region-code"] = "145" + }, + cz = { + ["alpha-2"] = "CZ", + ["alpha-3"] = "CZE", + ["country-code"] = "203", + ["iso_3166-2"] = "ISO 3166-2:CZ", + name = "Czech Republic", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Eastern Europe", + ["sub-region-code"] = "151" + }, + de = { + ["alpha-2"] = "DE", + ["alpha-3"] = "DEU", + ["country-code"] = "276", + ["iso_3166-2"] = "ISO 3166-2:DE", + name = "Germany", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Western Europe", + ["sub-region-code"] = "155" + }, + dj = { + ["alpha-2"] = "DJ", + ["alpha-3"] = "DJI", + ["country-code"] = "262", + ["iso_3166-2"] = "ISO 3166-2:DJ", + name = "Djibouti", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Eastern Africa", + ["sub-region-code"] = "014" + }, + dk = { + ["alpha-2"] = "DK", + ["alpha-3"] = "DNK", + ["country-code"] = "208", + ["iso_3166-2"] = "ISO 3166-2:DK", + name = "Denmark", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Northern Europe", + ["sub-region-code"] = "154" + }, + dm = { + ["alpha-2"] = "DM", + ["alpha-3"] = "DMA", + ["country-code"] = "212", + ["iso_3166-2"] = "ISO 3166-2:DM", + name = "Dominica", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + ["do"] = { + ["alpha-2"] = "DO", + ["alpha-3"] = "DOM", + ["country-code"] = "214", + ["iso_3166-2"] = "ISO 3166-2:DO", + name = "Dominican Republic", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + dz = { + ["alpha-2"] = "DZ", + ["alpha-3"] = "DZA", + ["country-code"] = "012", + ["iso_3166-2"] = "ISO 3166-2:DZ", + name = "Algeria", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Northern Africa", + ["sub-region-code"] = "015" + }, + ec = { + ["alpha-2"] = "EC", + ["alpha-3"] = "ECU", + ["country-code"] = "218", + ["iso_3166-2"] = "ISO 3166-2:EC", + name = "Ecuador", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "South America", + ["sub-region-code"] = "005" + }, + ee = { + ["alpha-2"] = "EE", + ["alpha-3"] = "EST", + ["country-code"] = "233", + ["iso_3166-2"] = "ISO 3166-2:EE", + name = "Estonia", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Northern Europe", + ["sub-region-code"] = "154" + }, + eg = { + ["alpha-2"] = "EG", + ["alpha-3"] = "EGY", + ["country-code"] = "818", + ["iso_3166-2"] = "ISO 3166-2:EG", + name = "Egypt", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Northern Africa", + ["sub-region-code"] = "015" + }, + eh = { + ["alpha-2"] = "EH", + ["alpha-3"] = "ESH", + ["country-code"] = "732", + ["iso_3166-2"] = "ISO 3166-2:EH", + name = "Western Sahara", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Northern Africa", + ["sub-region-code"] = "015" + }, + er = { + ["alpha-2"] = "ER", + ["alpha-3"] = "ERI", + ["country-code"] = "232", + ["iso_3166-2"] = "ISO 3166-2:ER", + name = "Eritrea", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Eastern Africa", + ["sub-region-code"] = "014" + }, + es = { + ["alpha-2"] = "ES", + ["alpha-3"] = "ESP", + ["country-code"] = "724", + ["iso_3166-2"] = "ISO 3166-2:ES", + name = "Spain", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Southern Europe", + ["sub-region-code"] = "039" + }, + et = { + ["alpha-2"] = "ET", + ["alpha-3"] = "ETH", + ["country-code"] = "231", + ["iso_3166-2"] = "ISO 3166-2:ET", + name = "Ethiopia", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Eastern Africa", + ["sub-region-code"] = "014" + }, + fi = { + ["alpha-2"] = "FI", + ["alpha-3"] = "FIN", + ["country-code"] = "246", + ["iso_3166-2"] = "ISO 3166-2:FI", + name = "Finland", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Northern Europe", + ["sub-region-code"] = "154" + }, + fj = { + ["alpha-2"] = "FJ", + ["alpha-3"] = "FJI", + ["country-code"] = "242", + ["iso_3166-2"] = "ISO 3166-2:FJ", + name = "Fiji", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Melanesia", + ["sub-region-code"] = "054" + }, + fk = { + ["alpha-2"] = "FK", + ["alpha-3"] = "FLK", + ["country-code"] = "238", + ["iso_3166-2"] = "ISO 3166-2:FK", + name = "Falkland Islands (Malvinas)", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "South America", + ["sub-region-code"] = "005" + }, + fm = { + ["alpha-2"] = "FM", + ["alpha-3"] = "FSM", + ["country-code"] = "583", + ["iso_3166-2"] = "ISO 3166-2:FM", + name = "Micronesia (Federated States of)", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Micronesia", + ["sub-region-code"] = "057" + }, + fo = { + ["alpha-2"] = "FO", + ["alpha-3"] = "FRO", + ["country-code"] = "234", + ["iso_3166-2"] = "ISO 3166-2:FO", + name = "Faroe Islands", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Northern Europe", + ["sub-region-code"] = "154" + }, + fr = { + ["alpha-2"] = "FR", + ["alpha-3"] = "FRA", + ["country-code"] = "250", + ["iso_3166-2"] = "ISO 3166-2:FR", + name = "France", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Western Europe", + ["sub-region-code"] = "155" + }, + ga = { + ["alpha-2"] = "GA", + ["alpha-3"] = "GAB", + ["country-code"] = "266", + ["iso_3166-2"] = "ISO 3166-2:GA", + name = "Gabon", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Middle Africa", + ["sub-region-code"] = "017" + }, + gb = { + ["alpha-2"] = "GB", + ["alpha-3"] = "GBR", + ["country-code"] = "826", + ["iso_3166-2"] = "ISO 3166-2:GB", + name = "United Kingdom of Great Britain and Northern Ireland", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Northern Europe", + ["sub-region-code"] = "154" + }, + gd = { + ["alpha-2"] = "GD", + ["alpha-3"] = "GRD", + ["country-code"] = "308", + ["iso_3166-2"] = "ISO 3166-2:GD", + name = "Grenada", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + ge = { + ["alpha-2"] = "GE", + ["alpha-3"] = "GEO", + ["country-code"] = "268", + ["iso_3166-2"] = "ISO 3166-2:GE", + name = "Georgia", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Western Asia", + ["sub-region-code"] = "145" + }, + gf = { + ["alpha-2"] = "GF", + ["alpha-3"] = "GUF", + ["country-code"] = "254", + ["iso_3166-2"] = "ISO 3166-2:GF", + name = "French Guiana", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "South America", + ["sub-region-code"] = "005" + }, + gg = { + ["alpha-2"] = "GG", + ["alpha-3"] = "GGY", + ["country-code"] = "831", + ["iso_3166-2"] = "ISO 3166-2:GG", + name = "Guernsey", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Northern Europe", + ["sub-region-code"] = "154" + }, + gh = { + ["alpha-2"] = "GH", + ["alpha-3"] = "GHA", + ["country-code"] = "288", + ["iso_3166-2"] = "ISO 3166-2:GH", + name = "Ghana", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Western Africa", + ["sub-region-code"] = "011" + }, + gi = { + ["alpha-2"] = "GI", + ["alpha-3"] = "GIB", + ["country-code"] = "292", + ["iso_3166-2"] = "ISO 3166-2:GI", + name = "Gibraltar", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Southern Europe", + ["sub-region-code"] = "039" + }, + gl = { + ["alpha-2"] = "GL", + ["alpha-3"] = "GRL", + ["country-code"] = "304", + ["iso_3166-2"] = "ISO 3166-2:GL", + name = "Greenland", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Northern America", + ["sub-region-code"] = "021" + }, + gm = { + ["alpha-2"] = "GM", + ["alpha-3"] = "GMB", + ["country-code"] = "270", + ["iso_3166-2"] = "ISO 3166-2:GM", + name = "Gambia", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Western Africa", + ["sub-region-code"] = "011" + }, + gn = { + ["alpha-2"] = "GN", + ["alpha-3"] = "GIN", + ["country-code"] = "324", + ["iso_3166-2"] = "ISO 3166-2:GN", + name = "Guinea", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Western Africa", + ["sub-region-code"] = "011" + }, + gp = { + ["alpha-2"] = "GP", + ["alpha-3"] = "GLP", + ["country-code"] = "312", + ["iso_3166-2"] = "ISO 3166-2:GP", + name = "Guadeloupe", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + gq = { + ["alpha-2"] = "GQ", + ["alpha-3"] = "GNQ", + ["country-code"] = "226", + ["iso_3166-2"] = "ISO 3166-2:GQ", + name = "Equatorial Guinea", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Middle Africa", + ["sub-region-code"] = "017" + }, + gr = { + ["alpha-2"] = "GR", + ["alpha-3"] = "GRC", + ["country-code"] = "300", + ["iso_3166-2"] = "ISO 3166-2:GR", + name = "Greece", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Southern Europe", + ["sub-region-code"] = "039" + }, + gs = { + ["alpha-2"] = "GS", + ["alpha-3"] = "SGS", + ["country-code"] = "239", + ["iso_3166-2"] = "ISO 3166-2:GS", + name = "South Georgia and the South Sandwich Islands" + }, + gt = { + ["alpha-2"] = "GT", + ["alpha-3"] = "GTM", + ["country-code"] = "320", + ["iso_3166-2"] = "ISO 3166-2:GT", + name = "Guatemala", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Central America", + ["sub-region-code"] = "013" + }, + gu = { + ["alpha-2"] = "GU", + ["alpha-3"] = "GUM", + ["country-code"] = "316", + ["iso_3166-2"] = "ISO 3166-2:GU", + name = "Guam", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Micronesia", + ["sub-region-code"] = "057" + }, + gw = { + ["alpha-2"] = "GW", + ["alpha-3"] = "GNB", + ["country-code"] = "624", + ["iso_3166-2"] = "ISO 3166-2:GW", + name = "Guinea-Bissau", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Western Africa", + ["sub-region-code"] = "011" + }, + gy = { + ["alpha-2"] = "GY", + ["alpha-3"] = "GUY", + ["country-code"] = "328", + ["iso_3166-2"] = "ISO 3166-2:GY", + name = "Guyana", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "South America", + ["sub-region-code"] = "005" + }, + hk = { + ["alpha-2"] = "HK", + ["alpha-3"] = "HKG", + ["country-code"] = "344", + ["iso_3166-2"] = "ISO 3166-2:HK", + name = "Hong Kong", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Eastern Asia", + ["sub-region-code"] = "030" + }, + hm = { + ["alpha-2"] = "HM", + ["alpha-3"] = "HMD", + ["country-code"] = "334", + ["iso_3166-2"] = "ISO 3166-2:HM", + name = "Heard Island and McDonald Islands" + }, + hn = { + ["alpha-2"] = "HN", + ["alpha-3"] = "HND", + ["country-code"] = "340", + ["iso_3166-2"] = "ISO 3166-2:HN", + name = "Honduras", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Central America", + ["sub-region-code"] = "013" + }, + hr = { + ["alpha-2"] = "HR", + ["alpha-3"] = "HRV", + ["country-code"] = "191", + ["iso_3166-2"] = "ISO 3166-2:HR", + name = "Croatia", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Southern Europe", + ["sub-region-code"] = "039" + }, + ht = { + ["alpha-2"] = "HT", + ["alpha-3"] = "HTI", + ["country-code"] = "332", + ["iso_3166-2"] = "ISO 3166-2:HT", + name = "Haiti", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + hu = { + ["alpha-2"] = "HU", + ["alpha-3"] = "HUN", + ["country-code"] = "348", + ["iso_3166-2"] = "ISO 3166-2:HU", + name = "Hungary", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Eastern Europe", + ["sub-region-code"] = "151" + }, + id = { + ["alpha-2"] = "ID", + ["alpha-3"] = "IDN", + ["country-code"] = "360", + ["iso_3166-2"] = "ISO 3166-2:ID", + name = "Indonesia", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "South-Eastern Asia", + ["sub-region-code"] = "035" + }, + ie = { + ["alpha-2"] = "IE", + ["alpha-3"] = "IRL", + ["country-code"] = "372", + ["iso_3166-2"] = "ISO 3166-2:IE", + name = "Ireland", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Northern Europe", + ["sub-region-code"] = "154" + }, + il = { + ["alpha-2"] = "IL", + ["alpha-3"] = "ISR", + ["country-code"] = "376", + ["iso_3166-2"] = "ISO 3166-2:IL", + name = "Israel", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Western Asia", + ["sub-region-code"] = "145" + }, + im = { + ["alpha-2"] = "IM", + ["alpha-3"] = "IMN", + ["country-code"] = "833", + ["iso_3166-2"] = "ISO 3166-2:IM", + name = "Isle of Man", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Northern Europe", + ["sub-region-code"] = "154" + }, + ["in"] = { + ["alpha-2"] = "IN", + ["alpha-3"] = "IND", + ["country-code"] = "356", + ["iso_3166-2"] = "ISO 3166-2:IN", + name = "India", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Southern Asia", + ["sub-region-code"] = "034" + }, + io = { + ["alpha-2"] = "IO", + ["alpha-3"] = "IOT", + ["country-code"] = "086", + ["iso_3166-2"] = "ISO 3166-2:IO", + name = "British Indian Ocean Territory" + }, + iq = { + ["alpha-2"] = "IQ", + ["alpha-3"] = "IRQ", + ["country-code"] = "368", + ["iso_3166-2"] = "ISO 3166-2:IQ", + name = "Iraq", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Western Asia", + ["sub-region-code"] = "145" + }, + ir = { + ["alpha-2"] = "IR", + ["alpha-3"] = "IRN", + ["country-code"] = "364", + ["iso_3166-2"] = "ISO 3166-2:IR", + name = "Iran (Islamic Republic of)", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Southern Asia", + ["sub-region-code"] = "034" + }, + is = { + ["alpha-2"] = "IS", + ["alpha-3"] = "ISL", + ["country-code"] = "352", + ["iso_3166-2"] = "ISO 3166-2:IS", + name = "Iceland", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Northern Europe", + ["sub-region-code"] = "154" + }, + it = { + ["alpha-2"] = "IT", + ["alpha-3"] = "ITA", + ["country-code"] = "380", + ["iso_3166-2"] = "ISO 3166-2:IT", + name = "Italy", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Southern Europe", + ["sub-region-code"] = "039" + }, + je = { + ["alpha-2"] = "JE", + ["alpha-3"] = "JEY", + ["country-code"] = "832", + ["iso_3166-2"] = "ISO 3166-2:JE", + name = "Jersey", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Northern Europe", + ["sub-region-code"] = "154" + }, + jm = { + ["alpha-2"] = "JM", + ["alpha-3"] = "JAM", + ["country-code"] = "388", + ["iso_3166-2"] = "ISO 3166-2:JM", + name = "Jamaica", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + jo = { + ["alpha-2"] = "JO", + ["alpha-3"] = "JOR", + ["country-code"] = "400", + ["iso_3166-2"] = "ISO 3166-2:JO", + name = "Jordan", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Western Asia", + ["sub-region-code"] = "145" + }, + jp = { + ["alpha-2"] = "JP", + ["alpha-3"] = "JPN", + ["country-code"] = "392", + ["iso_3166-2"] = "ISO 3166-2:JP", + name = "Japan", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Eastern Asia", + ["sub-region-code"] = "030" + }, + ke = { + ["alpha-2"] = "KE", + ["alpha-3"] = "KEN", + ["country-code"] = "404", + ["iso_3166-2"] = "ISO 3166-2:KE", + name = "Kenya", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Eastern Africa", + ["sub-region-code"] = "014" + }, + kg = { + ["alpha-2"] = "KG", + ["alpha-3"] = "KGZ", + ["country-code"] = "417", + ["iso_3166-2"] = "ISO 3166-2:KG", + name = "Kyrgyzstan", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Central Asia", + ["sub-region-code"] = "143" + }, + kh = { + ["alpha-2"] = "KH", + ["alpha-3"] = "KHM", + ["country-code"] = "116", + ["iso_3166-2"] = "ISO 3166-2:KH", + name = "Cambodia", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "South-Eastern Asia", + ["sub-region-code"] = "035" + }, + ki = { + ["alpha-2"] = "KI", + ["alpha-3"] = "KIR", + ["country-code"] = "296", + ["iso_3166-2"] = "ISO 3166-2:KI", + name = "Kiribati", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Micronesia", + ["sub-region-code"] = "057" + }, + km = { + ["alpha-2"] = "KM", + ["alpha-3"] = "COM", + ["country-code"] = "174", + ["iso_3166-2"] = "ISO 3166-2:KM", + name = "Comoros", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Eastern Africa", + ["sub-region-code"] = "014" + }, + kn = { + ["alpha-2"] = "KN", + ["alpha-3"] = "KNA", + ["country-code"] = "659", + ["iso_3166-2"] = "ISO 3166-2:KN", + name = "Saint Kitts and Nevis", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + kp = { + ["alpha-2"] = "KP", + ["alpha-3"] = "PRK", + ["country-code"] = "408", + ["iso_3166-2"] = "ISO 3166-2:KP", + name = "Korea (Democratic People's Republic of)", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Eastern Asia", + ["sub-region-code"] = "030" + }, + kr = { + ["alpha-2"] = "KR", + ["alpha-3"] = "KOR", + ["country-code"] = "410", + ["iso_3166-2"] = "ISO 3166-2:KR", + name = "Korea (Republic of)", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Eastern Asia", + ["sub-region-code"] = "030" + }, + kw = { + ["alpha-2"] = "KW", + ["alpha-3"] = "KWT", + ["country-code"] = "414", + ["iso_3166-2"] = "ISO 3166-2:KW", + name = "Kuwait", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Western Asia", + ["sub-region-code"] = "145" + }, + ky = { + ["alpha-2"] = "KY", + ["alpha-3"] = "CYM", + ["country-code"] = "136", + ["iso_3166-2"] = "ISO 3166-2:KY", + name = "Cayman Islands", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + kz = { + ["alpha-2"] = "KZ", + ["alpha-3"] = "KAZ", + ["country-code"] = "398", + ["iso_3166-2"] = "ISO 3166-2:KZ", + name = "Kazakhstan", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Central Asia", + ["sub-region-code"] = "143" + }, + la = { + ["alpha-2"] = "LA", + ["alpha-3"] = "LAO", + ["country-code"] = "418", + ["iso_3166-2"] = "ISO 3166-2:LA", + name = "Lao People's Democratic Republic", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "South-Eastern Asia", + ["sub-region-code"] = "035" + }, + lb = { + ["alpha-2"] = "LB", + ["alpha-3"] = "LBN", + ["country-code"] = "422", + ["iso_3166-2"] = "ISO 3166-2:LB", + name = "Lebanon", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Western Asia", + ["sub-region-code"] = "145" + }, + lc = { + ["alpha-2"] = "LC", + ["alpha-3"] = "LCA", + ["country-code"] = "662", + ["iso_3166-2"] = "ISO 3166-2:LC", + name = "Saint Lucia", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + li = { + ["alpha-2"] = "LI", + ["alpha-3"] = "LIE", + ["country-code"] = "438", + ["iso_3166-2"] = "ISO 3166-2:LI", + name = "Liechtenstein", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Western Europe", + ["sub-region-code"] = "155" + }, + lk = { + ["alpha-2"] = "LK", + ["alpha-3"] = "LKA", + ["country-code"] = "144", + ["iso_3166-2"] = "ISO 3166-2:LK", + name = "Sri Lanka", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Southern Asia", + ["sub-region-code"] = "034" + }, + lr = { + ["alpha-2"] = "LR", + ["alpha-3"] = "LBR", + ["country-code"] = "430", + ["iso_3166-2"] = "ISO 3166-2:LR", + name = "Liberia", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Western Africa", + ["sub-region-code"] = "011" + }, + ls = { + ["alpha-2"] = "LS", + ["alpha-3"] = "LSO", + ["country-code"] = "426", + ["iso_3166-2"] = "ISO 3166-2:LS", + name = "Lesotho", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Southern Africa", + ["sub-region-code"] = "018" + }, + lt = { + ["alpha-2"] = "LT", + ["alpha-3"] = "LTU", + ["country-code"] = "440", + ["iso_3166-2"] = "ISO 3166-2:LT", + name = "Lithuania", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Northern Europe", + ["sub-region-code"] = "154" + }, + lu = { + ["alpha-2"] = "LU", + ["alpha-3"] = "LUX", + ["country-code"] = "442", + ["iso_3166-2"] = "ISO 3166-2:LU", + name = "Luxembourg", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Western Europe", + ["sub-region-code"] = "155" + }, + lv = { + ["alpha-2"] = "LV", + ["alpha-3"] = "LVA", + ["country-code"] = "428", + ["iso_3166-2"] = "ISO 3166-2:LV", + name = "Latvia", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Northern Europe", + ["sub-region-code"] = "154" + }, + ly = { + ["alpha-2"] = "LY", + ["alpha-3"] = "LBY", + ["country-code"] = "434", + ["iso_3166-2"] = "ISO 3166-2:LY", + name = "Libya", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Northern Africa", + ["sub-region-code"] = "015" + }, + ma = { + ["alpha-2"] = "MA", + ["alpha-3"] = "MAR", + ["country-code"] = "504", + ["iso_3166-2"] = "ISO 3166-2:MA", + name = "Morocco", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Northern Africa", + ["sub-region-code"] = "015" + }, + mc = { + ["alpha-2"] = "MC", + ["alpha-3"] = "MCO", + ["country-code"] = "492", + ["iso_3166-2"] = "ISO 3166-2:MC", + name = "Monaco", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Western Europe", + ["sub-region-code"] = "155" + }, + md = { + ["alpha-2"] = "MD", + ["alpha-3"] = "MDA", + ["country-code"] = "498", + ["iso_3166-2"] = "ISO 3166-2:MD", + name = "Moldova (Republic of)", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Eastern Europe", + ["sub-region-code"] = "151" + }, + me = { + ["alpha-2"] = "ME", + ["alpha-3"] = "MNE", + ["country-code"] = "499", + ["iso_3166-2"] = "ISO 3166-2:ME", + name = "Montenegro", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Southern Europe", + ["sub-region-code"] = "039" + }, + mf = { + ["alpha-2"] = "MF", + ["alpha-3"] = "MAF", + ["country-code"] = "663", + ["iso_3166-2"] = "ISO 3166-2:MF", + name = "Saint Martin (French part)", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + mg = { + ["alpha-2"] = "MG", + ["alpha-3"] = "MDG", + ["country-code"] = "450", + ["iso_3166-2"] = "ISO 3166-2:MG", + name = "Madagascar", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Eastern Africa", + ["sub-region-code"] = "014" + }, + mh = { + ["alpha-2"] = "MH", + ["alpha-3"] = "MHL", + ["country-code"] = "584", + ["iso_3166-2"] = "ISO 3166-2:MH", + name = "Marshall Islands", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Micronesia", + ["sub-region-code"] = "057" + }, + mk = { + ["alpha-2"] = "MK", + ["alpha-3"] = "MKD", + ["country-code"] = "807", + ["iso_3166-2"] = "ISO 3166-2:MK", + name = "Macedonia (the former Yugoslav Republic of)", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Southern Europe", + ["sub-region-code"] = "039" + }, + ml = { + ["alpha-2"] = "ML", + ["alpha-3"] = "MLI", + ["country-code"] = "466", + ["iso_3166-2"] = "ISO 3166-2:ML", + name = "Mali", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Western Africa", + ["sub-region-code"] = "011" + }, + mm = { + ["alpha-2"] = "MM", + ["alpha-3"] = "MMR", + ["country-code"] = "104", + ["iso_3166-2"] = "ISO 3166-2:MM", + name = "Myanmar", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "South-Eastern Asia", + ["sub-region-code"] = "035" + }, + mn = { + ["alpha-2"] = "MN", + ["alpha-3"] = "MNG", + ["country-code"] = "496", + ["iso_3166-2"] = "ISO 3166-2:MN", + name = "Mongolia", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Eastern Asia", + ["sub-region-code"] = "030" + }, + mo = { + ["alpha-2"] = "MO", + ["alpha-3"] = "MAC", + ["country-code"] = "446", + ["iso_3166-2"] = "ISO 3166-2:MO", + name = "Macao", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Eastern Asia", + ["sub-region-code"] = "030" + }, + mp = { + ["alpha-2"] = "MP", + ["alpha-3"] = "MNP", + ["country-code"] = "580", + ["iso_3166-2"] = "ISO 3166-2:MP", + name = "Northern Mariana Islands", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Micronesia", + ["sub-region-code"] = "057" + }, + mq = { + ["alpha-2"] = "MQ", + ["alpha-3"] = "MTQ", + ["country-code"] = "474", + ["iso_3166-2"] = "ISO 3166-2:MQ", + name = "Martinique", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + mr = { + ["alpha-2"] = "MR", + ["alpha-3"] = "MRT", + ["country-code"] = "478", + ["iso_3166-2"] = "ISO 3166-2:MR", + name = "Mauritania", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Western Africa", + ["sub-region-code"] = "011" + }, + ms = { + ["alpha-2"] = "MS", + ["alpha-3"] = "MSR", + ["country-code"] = "500", + ["iso_3166-2"] = "ISO 3166-2:MS", + name = "Montserrat", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + mt = { + ["alpha-2"] = "MT", + ["alpha-3"] = "MLT", + ["country-code"] = "470", + ["iso_3166-2"] = "ISO 3166-2:MT", + name = "Malta", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Southern Europe", + ["sub-region-code"] = "039" + }, + mu = { + ["alpha-2"] = "MU", + ["alpha-3"] = "MUS", + ["country-code"] = "480", + ["iso_3166-2"] = "ISO 3166-2:MU", + name = "Mauritius", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Eastern Africa", + ["sub-region-code"] = "014" + }, + mv = { + ["alpha-2"] = "MV", + ["alpha-3"] = "MDV", + ["country-code"] = "462", + ["iso_3166-2"] = "ISO 3166-2:MV", + name = "Maldives", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Southern Asia", + ["sub-region-code"] = "034" + }, + mw = { + ["alpha-2"] = "MW", + ["alpha-3"] = "MWI", + ["country-code"] = "454", + ["iso_3166-2"] = "ISO 3166-2:MW", + name = "Malawi", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Eastern Africa", + ["sub-region-code"] = "014" + }, + mx = { + ["alpha-2"] = "MX", + ["alpha-3"] = "MEX", + ["country-code"] = "484", + ["iso_3166-2"] = "ISO 3166-2:MX", + name = "Mexico", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Central America", + ["sub-region-code"] = "013" + }, + my = { + ["alpha-2"] = "MY", + ["alpha-3"] = "MYS", + ["country-code"] = "458", + ["iso_3166-2"] = "ISO 3166-2:MY", + name = "Malaysia", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "South-Eastern Asia", + ["sub-region-code"] = "035" + }, + mz = { + ["alpha-2"] = "MZ", + ["alpha-3"] = "MOZ", + ["country-code"] = "508", + ["iso_3166-2"] = "ISO 3166-2:MZ", + name = "Mozambique", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Eastern Africa", + ["sub-region-code"] = "014" + }, + na = { + ["alpha-2"] = "NA", + ["alpha-3"] = "NAM", + ["country-code"] = "516", + ["iso_3166-2"] = "ISO 3166-2:NA", + name = "Namibia", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Southern Africa", + ["sub-region-code"] = "018" + }, + nc = { + ["alpha-2"] = "NC", + ["alpha-3"] = "NCL", + ["country-code"] = "540", + ["iso_3166-2"] = "ISO 3166-2:NC", + name = "New Caledonia", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Melanesia", + ["sub-region-code"] = "054" + }, + ne = { + ["alpha-2"] = "NE", + ["alpha-3"] = "NER", + ["country-code"] = "562", + ["iso_3166-2"] = "ISO 3166-2:NE", + name = "Niger", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Western Africa", + ["sub-region-code"] = "011" + }, + nf = { + ["alpha-2"] = "NF", + ["alpha-3"] = "NFK", + ["country-code"] = "574", + ["iso_3166-2"] = "ISO 3166-2:NF", + name = "Norfolk Island", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Australia and New Zealand", + ["sub-region-code"] = "053" + }, + ng = { + ["alpha-2"] = "NG", + ["alpha-3"] = "NGA", + ["country-code"] = "566", + ["iso_3166-2"] = "ISO 3166-2:NG", + name = "Nigeria", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Western Africa", + ["sub-region-code"] = "011" + }, + ni = { + ["alpha-2"] = "NI", + ["alpha-3"] = "NIC", + ["country-code"] = "558", + ["iso_3166-2"] = "ISO 3166-2:NI", + name = "Nicaragua", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Central America", + ["sub-region-code"] = "013" + }, + nl = { + ["alpha-2"] = "NL", + ["alpha-3"] = "NLD", + ["country-code"] = "528", + ["iso_3166-2"] = "ISO 3166-2:NL", + name = "Netherlands", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Western Europe", + ["sub-region-code"] = "155" + }, + no = { + ["alpha-2"] = "NO", + ["alpha-3"] = "NOR", + ["country-code"] = "578", + ["iso_3166-2"] = "ISO 3166-2:NO", + name = "Norway", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Northern Europe", + ["sub-region-code"] = "154" + }, + np = { + ["alpha-2"] = "NP", + ["alpha-3"] = "NPL", + ["country-code"] = "524", + ["iso_3166-2"] = "ISO 3166-2:NP", + name = "Nepal", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Southern Asia", + ["sub-region-code"] = "034" + }, + nr = { + ["alpha-2"] = "NR", + ["alpha-3"] = "NRU", + ["country-code"] = "520", + ["iso_3166-2"] = "ISO 3166-2:NR", + name = "Nauru", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Micronesia", + ["sub-region-code"] = "057" + }, + nu = { + ["alpha-2"] = "NU", + ["alpha-3"] = "NIU", + ["country-code"] = "570", + ["iso_3166-2"] = "ISO 3166-2:NU", + name = "Niue", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Polynesia", + ["sub-region-code"] = "061" + }, + nz = { + ["alpha-2"] = "NZ", + ["alpha-3"] = "NZL", + ["country-code"] = "554", + ["iso_3166-2"] = "ISO 3166-2:NZ", + name = "New Zealand", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Australia and New Zealand", + ["sub-region-code"] = "053" + }, + om = { + ["alpha-2"] = "OM", + ["alpha-3"] = "OMN", + ["country-code"] = "512", + ["iso_3166-2"] = "ISO 3166-2:OM", + name = "Oman", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Western Asia", + ["sub-region-code"] = "145" + }, + pa = { + ["alpha-2"] = "PA", + ["alpha-3"] = "PAN", + ["country-code"] = "591", + ["iso_3166-2"] = "ISO 3166-2:PA", + name = "Panama", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Central America", + ["sub-region-code"] = "013" + }, + pe = { + ["alpha-2"] = "PE", + ["alpha-3"] = "PER", + ["country-code"] = "604", + ["iso_3166-2"] = "ISO 3166-2:PE", + name = "Peru", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "South America", + ["sub-region-code"] = "005" + }, + pf = { + ["alpha-2"] = "PF", + ["alpha-3"] = "PYF", + ["country-code"] = "258", + ["iso_3166-2"] = "ISO 3166-2:PF", + name = "French Polynesia", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Polynesia", + ["sub-region-code"] = "061" + }, + pg = { + ["alpha-2"] = "PG", + ["alpha-3"] = "PNG", + ["country-code"] = "598", + ["iso_3166-2"] = "ISO 3166-2:PG", + name = "Papua New Guinea", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Melanesia", + ["sub-region-code"] = "054" + }, + ph = { + ["alpha-2"] = "PH", + ["alpha-3"] = "PHL", + ["country-code"] = "608", + ["iso_3166-2"] = "ISO 3166-2:PH", + name = "Philippines", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "South-Eastern Asia", + ["sub-region-code"] = "035" + }, + pk = { + ["alpha-2"] = "PK", + ["alpha-3"] = "PAK", + ["country-code"] = "586", + ["iso_3166-2"] = "ISO 3166-2:PK", + name = "Pakistan", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Southern Asia", + ["sub-region-code"] = "034" + }, + pl = { + ["alpha-2"] = "PL", + ["alpha-3"] = "POL", + ["country-code"] = "616", + ["iso_3166-2"] = "ISO 3166-2:PL", + name = "Poland", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Eastern Europe", + ["sub-region-code"] = "151" + }, + pm = { + ["alpha-2"] = "PM", + ["alpha-3"] = "SPM", + ["country-code"] = "666", + ["iso_3166-2"] = "ISO 3166-2:PM", + name = "Saint Pierre and Miquelon", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Northern America", + ["sub-region-code"] = "021" + }, + pn = { + ["alpha-2"] = "PN", + ["alpha-3"] = "PCN", + ["country-code"] = "612", + ["iso_3166-2"] = "ISO 3166-2:PN", + name = "Pitcairn", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Polynesia", + ["sub-region-code"] = "061" + }, + pr = { + ["alpha-2"] = "PR", + ["alpha-3"] = "PRI", + ["country-code"] = "630", + ["iso_3166-2"] = "ISO 3166-2:PR", + name = "Puerto Rico", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + ps = { + ["alpha-2"] = "PS", + ["alpha-3"] = "PSE", + ["country-code"] = "275", + ["iso_3166-2"] = "ISO 3166-2:PS", + name = "Palestine, State of", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Western Asia", + ["sub-region-code"] = "145" + }, + pt = { + ["alpha-2"] = "PT", + ["alpha-3"] = "PRT", + ["country-code"] = "620", + ["iso_3166-2"] = "ISO 3166-2:PT", + name = "Portugal", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Southern Europe", + ["sub-region-code"] = "039" + }, + pw = { + ["alpha-2"] = "PW", + ["alpha-3"] = "PLW", + ["country-code"] = "585", + ["iso_3166-2"] = "ISO 3166-2:PW", + name = "Palau", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Micronesia", + ["sub-region-code"] = "057" + }, + py = { + ["alpha-2"] = "PY", + ["alpha-3"] = "PRY", + ["country-code"] = "600", + ["iso_3166-2"] = "ISO 3166-2:PY", + name = "Paraguay", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "South America", + ["sub-region-code"] = "005" + }, + qa = { + ["alpha-2"] = "QA", + ["alpha-3"] = "QAT", + ["country-code"] = "634", + ["iso_3166-2"] = "ISO 3166-2:QA", + name = "Qatar", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Western Asia", + ["sub-region-code"] = "145" + }, + re = { + ["alpha-2"] = "RE", + ["alpha-3"] = "REU", + ["country-code"] = "638", + ["iso_3166-2"] = "ISO 3166-2:RE", + name = "Réunion", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Eastern Africa", + ["sub-region-code"] = "014" + }, + ro = { + ["alpha-2"] = "RO", + ["alpha-3"] = "ROU", + ["country-code"] = "642", + ["iso_3166-2"] = "ISO 3166-2:RO", + name = "Romania", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Eastern Europe", + ["sub-region-code"] = "151" + }, + rs = { + ["alpha-2"] = "RS", + ["alpha-3"] = "SRB", + ["country-code"] = "688", + ["iso_3166-2"] = "ISO 3166-2:RS", + name = "Serbia", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Southern Europe", + ["sub-region-code"] = "039" + }, + ru = { + ["alpha-2"] = "RU", + ["alpha-3"] = "RUS", + ["country-code"] = "643", + ["iso_3166-2"] = "ISO 3166-2:RU", + name = "Russian Federation", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Eastern Europe", + ["sub-region-code"] = "151" + }, + rw = { + ["alpha-2"] = "RW", + ["alpha-3"] = "RWA", + ["country-code"] = "646", + ["iso_3166-2"] = "ISO 3166-2:RW", + name = "Rwanda", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Eastern Africa", + ["sub-region-code"] = "014" + }, + sa = { + ["alpha-2"] = "SA", + ["alpha-3"] = "SAU", + ["country-code"] = "682", + ["iso_3166-2"] = "ISO 3166-2:SA", + name = "Saudi Arabia", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Western Asia", + ["sub-region-code"] = "145" + }, + sb = { + ["alpha-2"] = "SB", + ["alpha-3"] = "SLB", + ["country-code"] = "090", + ["iso_3166-2"] = "ISO 3166-2:SB", + name = "Solomon Islands", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Melanesia", + ["sub-region-code"] = "054" + }, + sc = { + ["alpha-2"] = "SC", + ["alpha-3"] = "SYC", + ["country-code"] = "690", + ["iso_3166-2"] = "ISO 3166-2:SC", + name = "Seychelles", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Eastern Africa", + ["sub-region-code"] = "014" + }, + sd = { + ["alpha-2"] = "SD", + ["alpha-3"] = "SDN", + ["country-code"] = "729", + ["iso_3166-2"] = "ISO 3166-2:SD", + name = "Sudan", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Northern Africa", + ["sub-region-code"] = "015" + }, + se = { + ["alpha-2"] = "SE", + ["alpha-3"] = "SWE", + ["country-code"] = "752", + ["iso_3166-2"] = "ISO 3166-2:SE", + name = "Sweden", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Northern Europe", + ["sub-region-code"] = "154" + }, + sg = { + ["alpha-2"] = "SG", + ["alpha-3"] = "SGP", + ["country-code"] = "702", + ["iso_3166-2"] = "ISO 3166-2:SG", + name = "Singapore", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "South-Eastern Asia", + ["sub-region-code"] = "035" + }, + sh = { + ["alpha-2"] = "SH", + ["alpha-3"] = "SHN", + ["country-code"] = "654", + ["iso_3166-2"] = "ISO 3166-2:SH", + name = "Saint Helena, Ascension and Tristan da Cunha", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Western Africa", + ["sub-region-code"] = "011" + }, + si = { + ["alpha-2"] = "SI", + ["alpha-3"] = "SVN", + ["country-code"] = "705", + ["iso_3166-2"] = "ISO 3166-2:SI", + name = "Slovenia", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Southern Europe", + ["sub-region-code"] = "039" + }, + sj = { + ["alpha-2"] = "SJ", + ["alpha-3"] = "SJM", + ["country-code"] = "744", + ["iso_3166-2"] = "ISO 3166-2:SJ", + name = "Svalbard and Jan Mayen", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Northern Europe", + ["sub-region-code"] = "154" + }, + sk = { + ["alpha-2"] = "SK", + ["alpha-3"] = "SVK", + ["country-code"] = "703", + ["iso_3166-2"] = "ISO 3166-2:SK", + name = "Slovakia", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Eastern Europe", + ["sub-region-code"] = "151" + }, + sl = { + ["alpha-2"] = "SL", + ["alpha-3"] = "SLE", + ["country-code"] = "694", + ["iso_3166-2"] = "ISO 3166-2:SL", + name = "Sierra Leone", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Western Africa", + ["sub-region-code"] = "011" + }, + sm = { + ["alpha-2"] = "SM", + ["alpha-3"] = "SMR", + ["country-code"] = "674", + ["iso_3166-2"] = "ISO 3166-2:SM", + name = "San Marino", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Southern Europe", + ["sub-region-code"] = "039" + }, + sn = { + ["alpha-2"] = "SN", + ["alpha-3"] = "SEN", + ["country-code"] = "686", + ["iso_3166-2"] = "ISO 3166-2:SN", + name = "Senegal", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Western Africa", + ["sub-region-code"] = "011" + }, + so = { + ["alpha-2"] = "SO", + ["alpha-3"] = "SOM", + ["country-code"] = "706", + ["iso_3166-2"] = "ISO 3166-2:SO", + name = "Somalia", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Eastern Africa", + ["sub-region-code"] = "014" + }, + sr = { + ["alpha-2"] = "SR", + ["alpha-3"] = "SUR", + ["country-code"] = "740", + ["iso_3166-2"] = "ISO 3166-2:SR", + name = "Suriname", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "South America", + ["sub-region-code"] = "005" + }, + ss = { + ["alpha-2"] = "SS", + ["alpha-3"] = "SSD", + ["country-code"] = "728", + ["iso_3166-2"] = "ISO 3166-2:SS", + name = "South Sudan", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Eastern Africa", + ["sub-region-code"] = "014" + }, + st = { + ["alpha-2"] = "ST", + ["alpha-3"] = "STP", + ["country-code"] = "678", + ["iso_3166-2"] = "ISO 3166-2:ST", + name = "Sao Tome and Principe", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Middle Africa", + ["sub-region-code"] = "017" + }, + sv = { + ["alpha-2"] = "SV", + ["alpha-3"] = "SLV", + ["country-code"] = "222", + ["iso_3166-2"] = "ISO 3166-2:SV", + name = "El Salvador", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Central America", + ["sub-region-code"] = "013" + }, + sx = { + ["alpha-2"] = "SX", + ["alpha-3"] = "SXM", + ["country-code"] = "534", + ["iso_3166-2"] = "ISO 3166-2:SX", + name = "Sint Maarten (Dutch part)", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + sy = { + ["alpha-2"] = "SY", + ["alpha-3"] = "SYR", + ["country-code"] = "760", + ["iso_3166-2"] = "ISO 3166-2:SY", + name = "Syrian Arab Republic", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Western Asia", + ["sub-region-code"] = "145" + }, + sz = { + ["alpha-2"] = "SZ", + ["alpha-3"] = "SWZ", + ["country-code"] = "748", + ["iso_3166-2"] = "ISO 3166-2:SZ", + name = "Swaziland", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Southern Africa", + ["sub-region-code"] = "018" + }, + tc = { + ["alpha-2"] = "TC", + ["alpha-3"] = "TCA", + ["country-code"] = "796", + ["iso_3166-2"] = "ISO 3166-2:TC", + name = "Turks and Caicos Islands", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + td = { + ["alpha-2"] = "TD", + ["alpha-3"] = "TCD", + ["country-code"] = "148", + ["iso_3166-2"] = "ISO 3166-2:TD", + name = "Chad", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Middle Africa", + ["sub-region-code"] = "017" + }, + tf = { + ["alpha-2"] = "TF", + ["alpha-3"] = "ATF", + ["country-code"] = "260", + ["iso_3166-2"] = "ISO 3166-2:TF", + name = "French Southern Territories" + }, + tg = { + ["alpha-2"] = "TG", + ["alpha-3"] = "TGO", + ["country-code"] = "768", + ["iso_3166-2"] = "ISO 3166-2:TG", + name = "Togo", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Western Africa", + ["sub-region-code"] = "011" + }, + th = { + ["alpha-2"] = "TH", + ["alpha-3"] = "THA", + ["country-code"] = "764", + ["iso_3166-2"] = "ISO 3166-2:TH", + name = "Thailand", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "South-Eastern Asia", + ["sub-region-code"] = "035" + }, + tj = { + ["alpha-2"] = "TJ", + ["alpha-3"] = "TJK", + ["country-code"] = "762", + ["iso_3166-2"] = "ISO 3166-2:TJ", + name = "Tajikistan", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Central Asia", + ["sub-region-code"] = "143" + }, + tk = { + ["alpha-2"] = "TK", + ["alpha-3"] = "TKL", + ["country-code"] = "772", + ["iso_3166-2"] = "ISO 3166-2:TK", + name = "Tokelau", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Polynesia", + ["sub-region-code"] = "061" + }, + tl = { + ["alpha-2"] = "TL", + ["alpha-3"] = "TLS", + ["country-code"] = "626", + ["iso_3166-2"] = "ISO 3166-2:TL", + name = "Timor-Leste", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "South-Eastern Asia", + ["sub-region-code"] = "035" + }, + tm = { + ["alpha-2"] = "TM", + ["alpha-3"] = "TKM", + ["country-code"] = "795", + ["iso_3166-2"] = "ISO 3166-2:TM", + name = "Turkmenistan", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Central Asia", + ["sub-region-code"] = "143" + }, + tn = { + ["alpha-2"] = "TN", + ["alpha-3"] = "TUN", + ["country-code"] = "788", + ["iso_3166-2"] = "ISO 3166-2:TN", + name = "Tunisia", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Northern Africa", + ["sub-region-code"] = "015" + }, + to = { + ["alpha-2"] = "TO", + ["alpha-3"] = "TON", + ["country-code"] = "776", + ["iso_3166-2"] = "ISO 3166-2:TO", + name = "Tonga", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Polynesia", + ["sub-region-code"] = "061" + }, + tr = { + ["alpha-2"] = "TR", + ["alpha-3"] = "TUR", + ["country-code"] = "792", + ["iso_3166-2"] = "ISO 3166-2:TR", + name = "Turkey", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Western Asia", + ["sub-region-code"] = "145" + }, + tt = { + ["alpha-2"] = "TT", + ["alpha-3"] = "TTO", + ["country-code"] = "780", + ["iso_3166-2"] = "ISO 3166-2:TT", + name = "Trinidad and Tobago", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + tv = { + ["alpha-2"] = "TV", + ["alpha-3"] = "TUV", + ["country-code"] = "798", + ["iso_3166-2"] = "ISO 3166-2:TV", + name = "Tuvalu", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Polynesia", + ["sub-region-code"] = "061" + }, + tw = { + ["alpha-2"] = "TW", + ["alpha-3"] = "TWN", + ["country-code"] = "158", + ["iso_3166-2"] = "ISO 3166-2:TW", + name = "Taiwan, Province of China", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Eastern Asia", + ["sub-region-code"] = "030" + }, + tz = { + ["alpha-2"] = "TZ", + ["alpha-3"] = "TZA", + ["country-code"] = "834", + ["iso_3166-2"] = "ISO 3166-2:TZ", + name = "Tanzania, United Republic of", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Eastern Africa", + ["sub-region-code"] = "014" + }, + ua = { + ["alpha-2"] = "UA", + ["alpha-3"] = "UKR", + ["country-code"] = "804", + ["iso_3166-2"] = "ISO 3166-2:UA", + name = "Ukraine", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Eastern Europe", + ["sub-region-code"] = "151" + }, + ug = { + ["alpha-2"] = "UG", + ["alpha-3"] = "UGA", + ["country-code"] = "800", + ["iso_3166-2"] = "ISO 3166-2:UG", + name = "Uganda", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Eastern Africa", + ["sub-region-code"] = "014" + }, + um = { + ["alpha-2"] = "UM", + ["alpha-3"] = "UMI", + ["country-code"] = "581", + ["iso_3166-2"] = "ISO 3166-2:UM", + name = "United States Minor Outlying Islands" + }, + us = { + ["alpha-2"] = "US", + ["alpha-3"] = "USA", + ["country-code"] = "840", + ["iso_3166-2"] = "ISO 3166-2:US", + name = "United States of America", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Northern America", + ["sub-region-code"] = "021" + }, + uy = { + ["alpha-2"] = "UY", + ["alpha-3"] = "URY", + ["country-code"] = "858", + ["iso_3166-2"] = "ISO 3166-2:UY", + name = "Uruguay", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "South America", + ["sub-region-code"] = "005" + }, + uz = { + ["alpha-2"] = "UZ", + ["alpha-3"] = "UZB", + ["country-code"] = "860", + ["iso_3166-2"] = "ISO 3166-2:UZ", + name = "Uzbekistan", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Central Asia", + ["sub-region-code"] = "143" + }, + va = { + ["alpha-2"] = "VA", + ["alpha-3"] = "VAT", + ["country-code"] = "336", + ["iso_3166-2"] = "ISO 3166-2:VA", + name = "Holy See", + region = "Europe", + ["region-code"] = "150", + ["sub-region"] = "Southern Europe", + ["sub-region-code"] = "039" + }, + vc = { + ["alpha-2"] = "VC", + ["alpha-3"] = "VCT", + ["country-code"] = "670", + ["iso_3166-2"] = "ISO 3166-2:VC", + name = "Saint Vincent and the Grenadines", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + ve = { + ["alpha-2"] = "VE", + ["alpha-3"] = "VEN", + ["country-code"] = "862", + ["iso_3166-2"] = "ISO 3166-2:VE", + name = "Venezuela (Bolivarian Republic of)", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "South America", + ["sub-region-code"] = "005" + }, + vg = { + ["alpha-2"] = "VG", + ["alpha-3"] = "VGB", + ["country-code"] = "092", + ["iso_3166-2"] = "ISO 3166-2:VG", + name = "Virgin Islands (British)", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + vi = { + ["alpha-2"] = "VI", + ["alpha-3"] = "VIR", + ["country-code"] = "850", + ["iso_3166-2"] = "ISO 3166-2:VI", + name = "Virgin Islands (U.S.)", + region = "Americas", + ["region-code"] = "019", + ["sub-region"] = "Caribbean", + ["sub-region-code"] = "029" + }, + vn = { + ["alpha-2"] = "VN", + ["alpha-3"] = "VNM", + ["country-code"] = "704", + ["iso_3166-2"] = "ISO 3166-2:VN", + name = "Viet Nam", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "South-Eastern Asia", + ["sub-region-code"] = "035" + }, + vu = { + ["alpha-2"] = "VU", + ["alpha-3"] = "VUT", + ["country-code"] = "548", + ["iso_3166-2"] = "ISO 3166-2:VU", + name = "Vanuatu", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Melanesia", + ["sub-region-code"] = "054" + }, + wf = { + ["alpha-2"] = "WF", + ["alpha-3"] = "WLF", + ["country-code"] = "876", + ["iso_3166-2"] = "ISO 3166-2:WF", + name = "Wallis and Futuna", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Polynesia", + ["sub-region-code"] = "061" + }, + ws = { + ["alpha-2"] = "WS", + ["alpha-3"] = "WSM", + ["country-code"] = "882", + ["iso_3166-2"] = "ISO 3166-2:WS", + name = "Samoa", + region = "Oceania", + ["region-code"] = "009", + ["sub-region"] = "Polynesia", + ["sub-region-code"] = "061" + }, + ye = { + ["alpha-2"] = "YE", + ["alpha-3"] = "YEM", + ["country-code"] = "887", + ["iso_3166-2"] = "ISO 3166-2:YE", + name = "Yemen", + region = "Asia", + ["region-code"] = "142", + ["sub-region"] = "Western Asia", + ["sub-region-code"] = "145" + }, + yt = { + ["alpha-2"] = "YT", + ["alpha-3"] = "MYT", + ["country-code"] = "175", + ["iso_3166-2"] = "ISO 3166-2:YT", + name = "Mayotte", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Eastern Africa", + ["sub-region-code"] = "014" + }, + za = { + ["alpha-2"] = "ZA", + ["alpha-3"] = "ZAF", + ["country-code"] = "710", + ["iso_3166-2"] = "ISO 3166-2:ZA", + name = "South Africa", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Southern Africa", + ["sub-region-code"] = "018" + }, + zm = { + ["alpha-2"] = "ZM", + ["alpha-3"] = "ZMB", + ["country-code"] = "894", + ["iso_3166-2"] = "ISO 3166-2:ZM", + name = "Zambia", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Eastern Africa", + ["sub-region-code"] = "014" + }, + zw = { + ["alpha-2"] = "ZW", + ["alpha-3"] = "ZWE", + ["country-code"] = "716", + ["iso_3166-2"] = "ISO 3166-2:ZW", + name = "Zimbabwe", + region = "Africa", + ["region-code"] = "002", + ["sub-region"] = "Eastern Africa", + ["sub-region-code"] = "014" + } +} + -- 2.43.0 From d176696fc9deca5390cfb1937849e66bc84cddcf Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 15 Mar 2023 09:26:11 +0400 Subject: [PATCH 013/204] Move calenadar search script to communty folder --- {main => community}/calendar-search.lua | 1 - 1 file changed, 1 deletion(-) rename {main => community}/calendar-search.lua (91%) diff --git a/main/calendar-search.lua b/community/calendar-search.lua similarity index 91% rename from main/calendar-search.lua rename to community/calendar-search.lua index 24ab613..2b0c275 100644 --- a/main/calendar-search.lua +++ b/community/calendar-search.lua @@ -21,6 +21,5 @@ function on_search(str) end function on_click(idx) - --calendar:show_event_dialog(results[idx].id) calendar:open_event(results[idx].id) end -- 2.43.0 From 0f088a0708156f1c54b2de8e29ab7714ab71afdc Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 15 Mar 2023 09:26:44 +0400 Subject: [PATCH 014/204] Update scripts.zip --- scripts.index | 1 - scripts.md5 | 2 +- scripts.zip | Bin 20227 -> 19770 bytes 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts.index b/scripts.index index da3f458..8eec024 100644 --- a/scripts.index +++ b/scripts.index @@ -1,6 +1,5 @@ battery-widget.lua calendar.lua -calendar-search.lua covid-widget.lua dice-widget.lua facts-widget.lua diff --git a/scripts.md5 b/scripts.md5 index 1aa7fdb..56a8564 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -76a6d46d68c10a6b352504b4c2cd0331 +2fd70039f1c25140f305113e35a3b05a diff --git a/scripts.zip b/scripts.zip index b58c39dd02eff24d54cba1fcbd8e641a4a809ef1..66828a9343241315f829d1dba24b8d8643cc462f 100644 GIT binary patch delta 389 zcmZpk$GB@2;{;2VH{V!OHriff1T!`ZF+Jy)oXMjL;mzU+VS=ze@%2JgGz-*1Su8>| zP*#hu2n$5r9C0bA*e;1eC`(_e2+CS2eHhBhk*(r_=y;{RgBikFroD?5!b&kb54G3a z#09FO-n4=TBKzCX4k~NwvH>dl(KVK7@^TM3ruSTvk9&kLdGJn_^$cdZ!8f_cGla=U zVDbsiMCQwa43iUtB`4SVDNRoIl4E)+I=S5|f{9Oj@deGt9_%G zyc{O8`$h5eI599}7N;au=BK4i7W6Zlyx32Q$;oB%em^rl5e5;4KWq#P8g2|g007-V BkU;a91DH`-og1T!`ZF+Jy~U+Ntm`qt^|LuEz=h7cwO24MynhUCPY z)V!3$BHiND#G>R3y`0j-&=5`rX0?kU$si+2E4UdLSza(RFo22D2^X^t8}PW^|0}x4 z-_Yb|gF~XhH(_bj9osH->@3fROW8n1FDvd?x;o!DFd zNjmU)f4rAWW^GkW~d zDsB6w4CR*6sK^7xMLeG!^!;*Qh7>W{w4F?Q^fC6z(-F7YZLinb)oxY!yLC57fUiQf;LyF?O=xJ zHPhO~3SoWGKM%F{xRDD~2fs-L4@9=x!44{W)@cJ&w$UY)$r>|(NHBl^FugD=X?)Mc zfIYde0+Y*RLr=NM_uS-|;&~?ja|>bG!8bX?J($TuVDd`$5T-qXlmELXGCK=1O#UD! zIhoH_Vv;x4 Date: Thu, 16 Mar 2023 10:30:54 +0400 Subject: [PATCH 015/204] Add health widget to the Widgets switcher script --- main/widgets-on-off.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main/widgets-on-off.lua b/main/widgets-on-off.lua index 5b40518..850e2e4 100644 --- a/main/widgets-on-off.lua +++ b/main/widgets-on-off.lua @@ -7,11 +7,11 @@ --constants-- -local widgets = {"weather","weatheronly","clock","alarm","worldclock","monitor","traffic","player","apps","appbox","applist","contacts","notify","dialogs","dialer","timer","stopwatch","mail","notes","tasks","feed","telegram","twitter","calendar","exchange","finance","bitcoin","control","recorder","calculator","empty","bluetooth","map","remote"} +local widgets = {"weather","weatheronly","clock","alarm","worldclock","monitor","traffic","player","apps","appbox","applist","contacts","notify","dialogs","dialer","timer","stopwatch","mail","notes","tasks", "health", "feed","telegram","twitter","calendar","exchange","finance","bitcoin","control","recorder","calculator","empty","bluetooth","map","remote"} -local icons = {"fa:user-clock","fa:sun-cloud","fa:clock","fa:alarm-clock","fa:business-time","fa:network-wired","fa:exchange","fa:play-circle","fa:robot","fa:th","fa:list","fa:address-card","fa:bell","fa:comment-alt-minus","fa:phone-alt","fa:chess-clock","fa:stopwatch","fa:at","fa:sticky-note","fa:calendar-check","fa:rss-square","fa:paper-plane","fa:dove","fa:calendar-alt","fa:euro-sign","fa:chart-line","fa:coins","fa:wifi","fa:microphone-alt","fa:calculator-alt","fa:eraser","fa:head-side-headphones","fa:map-marked-alt","fa:user-tag"} +local icons = {"fa:user-clock","fa:sun-cloud","fa:clock","fa:alarm-clock","fa:business-time","fa:network-wired","fa:exchange","fa:play-circle","fa:robot","fa:th","fa:list","fa:address-card","fa:bell","fa:comment-alt-minus","fa:phone-alt","fa:chess-clock","fa:stopwatch","fa:at","fa:sticky-note","fa:calendar-check", "fa:heart", "fa:rss-square","fa:paper-plane","fa:dove","fa:calendar-alt","fa:euro-sign","fa:chart-line","fa:coins","fa:wifi","fa:microphone-alt","fa:calculator-alt","fa:eraser","fa:head-side-headphones","fa:map-marked-alt","fa:user-tag"} -local names = {"Clock & weather","Weather","Clock","Alarm","Worldclock","Monitor","Traffic","Player","Frequent apps","My apps","App list","Contacts","Notify","Dialogs","Dialer","Timer","Stopwatch","Mail","Notes","Tasks","Feed","Telegram","Twitter","Calendar","Exchange","Finance","Bitcoin","Control panel","Recorder","Calculator","Empty widget","Bluetooth","Map","User widget"} +local names = {"Clock & weather","Weather","Clock","Alarm","Worldclock","Monitor","Traffic","Player","Frequent apps","My apps","App list","Contacts","Notify","Dialogs","Dialer","Timer","Stopwatch","Mail","Notes","Tasks", "Health", "Feed","Telegram","Twitter","Calendar","Exchange","Finance","Bitcoin","Control panel","Recorder","Calculator","Empty widget","Bluetooth","Map","User widget"} --variables-- -- 2.43.0 From 2c6d5ffb288ee154801832985e1c3248776fef17 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 16 Mar 2023 10:31:13 +0400 Subject: [PATCH 016/204] Update scripts.zip --- scripts.md5 | 2 +- scripts.zip | Bin 19770 -> 19788 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts.md5 b/scripts.md5 index 56a8564..57f2b7a 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -2fd70039f1c25140f305113e35a3b05a +036867fef274dcbf6103cd73adb65e47 diff --git a/scripts.zip b/scripts.zip index 66828a9343241315f829d1dba24b8d8643cc462f..05a0e3737f822054236d1f69f9b831bdda3dde34 100644 GIT binary patch delta 1731 zcmZ9NdpHve8^*UW!dT{<<0QV3W5`&U^I>Au5Tg?L?Bk6L4Y7!@LTypzd|tJdHM7^@ z#gbFhLXksdp_Dgtkeu?q*?-@2UC;CUuIIl0zMmF4aF7nXjuiXEg|Sh?z~7rA4^ooa z0fdY%Xa~|{^F$I1nkoX??i3Lyz?8&yJVwguqKk)0tO(jwi6XGv^H>BM>dDeO=0tsp zm~8*?7{9L|joEZC0C1DG+fa*~$b*Ib?s$?604P2$1_11gzx?shlh%rbkZU+dpxGt*UOEj2S*+#dY?PzSv6So5~gSI^tN6xxdO1?kXS`Yk20*Nzt5F^ z%m}X;8dNQ`!zYZ{xSbT-V3ucn|{k=>(1R`O%Fl}A|b*G}ml{Kupl+C418R8z&mBE7P7rR=B2@xZz+wLz% zwZ#uA|6xcVgx@eKm;S6QLU25V3QvqTAcjWAR;6bPl#O6mkUINf>vZj+G7XRQr`r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S=PRH5U$b=(fO#$Je$pg7bP z&=)t9ck+fnt^Qau+{WwX8vFj*Z;1NkNDoV-xz$c|-ixo*6w0&4rkD)^vP$dEjdEtuGLTFwQE3DnX#&lIx7Xp$~R!;|Bv;_ zfMxhKvVAdRJzcpwHPfiJLOds~Hz@dI1V3mD7r_V$3Z&_D(l@oF*uRvgE+A-%!zPAH z%uY&};a>NuN?#rm&_n?mgdof~>PD5wyp^C(-Z^}6GPsvLkR5bV!_?$sxYAGA0OoVL z3t~Rt(F^V|R<&x>Qgs&eyPKXR(RL zrT$V7!sY;}tWTG`jKy3*k6Dgc4ZD-3trY3|0^T{_a_*WDCj?BOyr4el1Gmzk?dBQw zr4I&?9XIbE>^+~+76@utzaNYF_8{bo$vhb<9+7HD*82WjM@4tRZ)<&*FblqnUHP6! zbC&V*36)lCwWAApY51;tRq^GLOWJ~}&#Eb_?KQtnJnV~`E6N?G3+vz7-?`LcYgBS- zL-z*ZknM2j}7)Z|LOIh4Yv#j!V-;Gh($8OVahF81LiQrDzSj5SU zb#b_ialR?5gUT!oK2w3BKhIqR6oEQ2A+1422HIq8CV~UV+$b67L|{x%mZP6BYBpSj zR|9;?FFI!T8l$Z_FQRMytU-KSi;H0&nh)C^b~P(Jlv%K_NTaq>D2%;pq(1uML?25>g5bvei*aJC18 jgCQ9JJvm27fxrUJ15%&@-W9-!ch&i!QDF38z>oJ2ioYr< -- 2.43.0 From f47bc68a39fb7381a899a8966b97c751a8d03e20 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 21 Mar 2023 17:19:38 +0400 Subject: [PATCH 017/204] update to fontawesome 6.3.0 --- README.md | 5 +++-- main/widgets-on-off.lua | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 23aabbb..bee3025 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,8 @@ The type of script is determined by the line (meta tag) at the beginning of the * 4.5.6 - `aio:active_widgets()` now returns also widget `label`, added `checks` module; * 4.5.7 - added "fold" and "unfold" actions to the `on_action` callback; * 4.6.0 - added `system:request_location()` and `tasker:send_command()` functions; -* 4.7.0 - added `ui:build()` and functions to display search results in different formats. +* 4.7.0 - added `ui:build()` and functions to display search results in different formats; +* 4.7.1 - fontawesome updated to version 6.3.0. # Widget scripts @@ -115,7 +116,7 @@ First line
Second line You can also use Markdown markup. To do this, add the prefix `%%mkd%%` to the beginning of the line. Or you can disable the formatting completely with the prefix `%%txt%%`. -The `ui:show_buttons()` function supports Fontawesome icons. Simply specify `fa:icon_name` as the button name, for example: `fa:play`. (Note: AIO only supports icons up to Fontawesome 5.12.) +The `ui:show_buttons()` function supports Fontawesome icons. Simply specify `fa:icon_name` as the button name, for example: `fa:play`. (Note: AIO only supports icons up to Fontawesome 6.3.0.) ## Dialogs diff --git a/main/widgets-on-off.lua b/main/widgets-on-off.lua index 850e2e4..d6ff2de 100644 --- a/main/widgets-on-off.lua +++ b/main/widgets-on-off.lua @@ -9,7 +9,7 @@ local widgets = {"weather","weatheronly","clock","alarm","worldclock","monitor","traffic","player","apps","appbox","applist","contacts","notify","dialogs","dialer","timer","stopwatch","mail","notes","tasks", "health", "feed","telegram","twitter","calendar","exchange","finance","bitcoin","control","recorder","calculator","empty","bluetooth","map","remote"} -local icons = {"fa:user-clock","fa:sun-cloud","fa:clock","fa:alarm-clock","fa:business-time","fa:network-wired","fa:exchange","fa:play-circle","fa:robot","fa:th","fa:list","fa:address-card","fa:bell","fa:comment-alt-minus","fa:phone-alt","fa:chess-clock","fa:stopwatch","fa:at","fa:sticky-note","fa:calendar-check", "fa:heart", "fa:rss-square","fa:paper-plane","fa:dove","fa:calendar-alt","fa:euro-sign","fa:chart-line","fa:coins","fa:wifi","fa:microphone-alt","fa:calculator-alt","fa:eraser","fa:head-side-headphones","fa:map-marked-alt","fa:user-tag"} +local icons = {"fa:user-clock","fa:sun-cloud","fa:clock","fa:alarm-clock","fa:business-time","fa:network-wired","fa:exchange","fa:play-circle","fa:robot","fa:th","fa:list","fa:address-card","fa:bell","fa:comment-alt-minus","fa:phone-alt","fa:chess-clock","fa:stopwatch","fa:at","fa:sticky-note","fa:calendar-check", "fa:heart-pulse", "fa:rss-square","fa:paper-plane","fa:dove","fa:calendar-alt","fa:euro-sign","fa:chart-line","fa:coins","fa:wifi","fa:microphone-alt","fa:calculator-alt","fa:eraser","fa:head-side-headphones","fa:map-marked-alt","fa:user-tag"} local names = {"Clock & weather","Weather","Clock","Alarm","Worldclock","Monitor","Traffic","Player","Frequent apps","My apps","App list","Contacts","Notify","Dialogs","Dialer","Timer","Stopwatch","Mail","Notes","Tasks", "Health", "Feed","Telegram","Twitter","Calendar","Exchange","Finance","Bitcoin","Control panel","Recorder","Calculator","Empty widget","Bluetooth","Map","User widget"} -- 2.43.0 From 706b3bec25e8327daae7bbe0dd0ed8fe8d67de0a Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 29 Mar 2023 13:54:44 +0400 Subject: [PATCH 018/204] add search settings sample --- samples/search-settings-test.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 samples/search-settings-test.lua diff --git a/samples/search-settings-test.lua b/samples/search-settings-test.lua new file mode 100644 index 0000000..d3a8d8b --- /dev/null +++ b/samples/search-settings-test.lua @@ -0,0 +1,19 @@ +-- type = "search" + +settings_init = false + +function on_search() + if not settings_init then + search:show_buttons{ "Set settings" } + else + search:show_buttons{ "Result #1", "Result #2" } + end +end + +function on_click(idx) + if not settings_init then + settings:show_dialog() + else + -- main work + end +end -- 2.43.0 From f2cef5d080e24c15914db7380793a54ad8df6af2 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 3 Apr 2023 10:20:31 +0400 Subject: [PATCH 019/204] move horoscope widget to defunct (API is not working anymore) --- {community => defunct}/horoscope-widget.lua | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {community => defunct}/horoscope-widget.lua (100%) diff --git a/community/horoscope-widget.lua b/defunct/horoscope-widget.lua similarity index 100% rename from community/horoscope-widget.lua rename to defunct/horoscope-widget.lua -- 2.43.0 From b94901d741ce4c6e1b831a5468fdbcb448368d6c Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 12 Apr 2023 12:42:32 +0400 Subject: [PATCH 020/204] Add calendar event status and color to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index bee3025..b051f3d 100644 --- a/README.md +++ b/README.md @@ -351,6 +351,8 @@ Event table format: * `calendar_id` - calendar ID; * `title` - title of the event; * `description` - description of the event; +* `color` - color of the event; +* `status` - status string of the event or empty; * `location` - address of the event by string; * `begin` - start time of the event (in seconds); * `end` - time of the event end (in seconds); -- 2.43.0 From 291d3ef446be3cba4181e9f1c030626b35a17b95 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 18 Apr 2023 15:13:44 +0400 Subject: [PATCH 021/204] fix README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b051f3d..989edbc 100644 --- a/README.md +++ b/README.md @@ -274,6 +274,7 @@ Intent table format (all fields are optional): Format of table elements returned by `aio:available_widgets()`: * `name` - internal name of the widget; +* `label` - title of the widget; * `type` - widget type: `builtin`, `script` or `plugin`; * `description` - widget description (usually empty for non-script widgets); * `clonable` - true if the widget can have clones (examples: "My apps", "Contacts", "Mailbox" widgets); -- 2.43.0 From c7a096d011398468e731fb93b3bb84aadd708653 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 20 May 2023 09:19:00 +0400 Subject: [PATCH 022/204] Add meta widget script --- community/meta-widget.lua | 166 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 community/meta-widget.lua diff --git a/community/meta-widget.lua b/community/meta-widget.lua new file mode 100644 index 0000000..d455b0f --- /dev/null +++ b/community/meta-widget.lua @@ -0,0 +1,166 @@ +-- name = "Meta widget" +-- type = "widget" +-- author = "Andrey Gavrilov" +-- version = "1.0" + +local widgets = { + "text [TEXT]", + "battery", + "notes [NUM]", + "exchange [NUM] [FROM] [TO]", + "worldclock [TIME_ZONE]", + "calendar [NUM]", + "bitcoin", + "traffic", + "alarm", + "tasks [NUM]", + "memory", + "storage", + "weather [NUM]", + "notify [NUM]", + "screen", + "dialogs [NUM]", + "player", + "health", + "space [NUM]" +} + +table.sort(widgets) + +function on_resume() + if not metawidget then + if not files:read("metawidget") then + metawidget = {"text Metawidget"} + redraw() + return + end + end + metawidget = load("return " .. files:read("metawidget"))() + ui:build(metawidget) +end + +function on_settings() + dialog_id = "settings" + ui:show_radio_dialog("Select action", {"Add widget", "Remove widget", "Move widget", "Edit widget", "Edit metawidget"}) +end + +function on_dialog_action(res) + if dialog_id == "settings" then + if res == 1 then + dialog_id = "add" + ui:show_radio_dialog("Add widget", widgets) + elseif res == 2 then + dialog_id = "remove" + ui:show_radio_dialog("Remove widget", metawidget) + elseif res == 3 then + dialog_id = "move" + ui:show_radio_dialog("Move widget", metawidget) + elseif res == 4 then + dialog_id = "edit" + ui:show_radio_dialog("Edit widget", metawidget) + elseif res == 5 then + dialog_id = "metaedit" + ui:show_rich_editor({text = "{\n\"" .. table.concat(metawidget, "\",\n\"") .. "\",\n}", new = true}) + else + dialog_id = "" + end + elseif dialog_id == "add" then + dialog_id = "" + if res ~= -1 then + add_widget(res) + end + elseif dialog_id == "remove" then + dialog_id = "" + if res ~= -1 then + remove_widget(res) + end + elseif dialog_id == "move" then + if res == -1 then + dialog_id = "" + else + dialog_id = "move_line" + pos = res + ui:show_radio_dialog("Remove widget", {"Up", "Down"}) + end + elseif dialog_id == "edit" then + if res == -1 then + dialog_id = "" + else + dialog_id = "edit_line" + pos = res + ui:show_edit_dialog("Edit widget", "", metawidget[res]) + end + elseif dialog_id == "metaedit" then + dialog_id = "" + if res ~= -1 then + metawidget = load("return " .. res.text)() + redraw() + end + elseif dialog_id == "add_line" then + dialog_id = "" + if (res ~= -1) and (res ~= "") then + table.insert(metawidget, res) + redraw() + end + elseif dialog_id == "move_line" then + dialog_id = "" + if res ~= -1 then + move_widget(res) + end + elseif dialog_id == "edit_line" then + dialog_id = "" + if res ~= -1 then + if res == "" then + remove_widget(pos) + else + metawidget[pos] = res + redraw() + end + end + else + return + end +end + +function add_widget(res) + local lines = widgets[res]:split(" ") + local line = lines[1] + if line == widgets[res] then + table.insert(metawidget, line) + redraw() + else + dialog_id = "add_line" + ui:show_edit_dialog("Enter parameters" .. widgets[res]:replace(line, ""), widgets[res], line .. " ") + end +end + +function remove_widget(res) + table.remove(metawidget, res) + redraw() +end + +function move_widget(res) + if res == 1 then + if pos == 1 then + return + else + local line = metawidget[pos] + metawidget[pos] = metawidget[pos - 1] + metawidget[pos - 1] = line + end + else + if pos == #metawidget then + return + else + local line = metawidget[pos] + metawidget[pos] = metawidget[pos + 1] + metawidget[pos + 1] = line + end + end + redraw() +end + +function redraw() + files:write("metawidget", "{\n\"" .. table.concat(metawidget, "\",\n\"") .. "\",\n}") + on_resume() +end -- 2.43.0 From 43856c1fc16d04aa94e5db9434cf548798d3d786 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 20 May 2023 09:25:39 +0400 Subject: [PATCH 023/204] Add prefs module --- README.md | 24 +++++++++++++++++++++++- samples/prefs-widget.lua | 8 ++++++++ samples/prefs-widget2.lua | 10 ++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 samples/prefs-widget.lua create mode 100644 samples/prefs-widget2.lua diff --git a/README.md b/README.md index 989edbc..a521e0a 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,8 @@ The type of script is determined by the line (meta tag) at the beginning of the * 4.5.7 - added "fold" and "unfold" actions to the `on_action` callback; * 4.6.0 - added `system:request_location()` and `tasker:send_command()` functions; * 4.7.0 - added `ui:build()` and functions to display search results in different formats; -* 4.7.1 - fontawesome updated to version 6.3.0. +* 4.7.1 - fontawesome updated to version 6.3.0; +* 4.7.4 - added `prefs` module, `settings` module is deprecated. # Widget scripts @@ -451,6 +452,8 @@ All files are created in the subdirectory `/sdcard/Android/data/ru.execbit.aiola ## Settings +_Deprecated in 4.7.4. Use prefs module.` + * `settings:get()` - returns the settings table in an array of words format; * `settings:set(table)` - saves the settings table in an array of words format; * `settings:get_kv()` - returns the settings table in `key=value` format; @@ -461,6 +464,25 @@ User can change settings through the dialog, which is available by clicking on t The standard edit dialog can be replaced by your own if you implement the `on_settings()` function. +## Preferences + +The `prefs` module is designed to permanently store the script settings. It is a simple Lua table which saves to disk all the data written to it. + +You can use it just like any other table with the exception that it cannot be used as a raw array. + +Sample: + +``` +prefs = require "prefs" + +function on_resume() + prefs.new_key = "Hello" + ui:show_lines{prefs.new_key} +end +``` + +The `new_key` will be present in the table even after the AIO Launcher has been restrated. + ## Animation and real time updates _Available only in widget scripts._ diff --git a/samples/prefs-widget.lua b/samples/prefs-widget.lua new file mode 100644 index 0000000..a3ad2de --- /dev/null +++ b/samples/prefs-widget.lua @@ -0,0 +1,8 @@ +prefs = require "prefs" + +prefs._name = "preferencies" + +function on_resume() + prefs.new_key = "Hello" + ui:show_lines{prefs.new_key} +end diff --git a/samples/prefs-widget2.lua b/samples/prefs-widget2.lua new file mode 100644 index 0000000..433bda9 --- /dev/null +++ b/samples/prefs-widget2.lua @@ -0,0 +1,10 @@ +prefs = require("prefs") + +prefs._name = "zzz" + +function on_resume() + prefs[1] = "text Battery level" + prefs[2] = "space" + prefs[3] = "battery" + ui:build(prefs) +end -- 2.43.0 From e872af804e067035d6442f509aeace15113db1f4 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 20 May 2023 09:28:35 +0400 Subject: [PATCH 024/204] Add prefs module --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a521e0a..ced6439 100644 --- a/README.md +++ b/README.md @@ -452,7 +452,7 @@ All files are created in the subdirectory `/sdcard/Android/data/ru.execbit.aiola ## Settings -_Deprecated in 4.7.4. Use prefs module.` +_Deprecated in 4.7.4. Use prefs module._ * `settings:get()` - returns the settings table in an array of words format; * `settings:set(table)` - saves the settings table in an array of words format; -- 2.43.0 From a1644fe13772b926636967292d10b385e70e4e44 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 25 May 2023 09:16:53 +0400 Subject: [PATCH 025/204] Add armenian alphabet widget --- community/arm-ru-abc-widget.lua | 66 +++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 community/arm-ru-abc-widget.lua diff --git a/community/arm-ru-abc-widget.lua b/community/arm-ru-abc-widget.lua new file mode 100644 index 0000000..2fd4d18 --- /dev/null +++ b/community/arm-ru-abc-widget.lua @@ -0,0 +1,66 @@ +-- name = "Армянский алфавит" +-- description = "Армянский алфавит с транскрипцией" +-- type = "widget" +-- author = "Evgeny Zobnin (zobnin@gmail.com)" +-- version = "1.0" +-- lang = "ru" + +local tab = { +{ + "Աա", "А", + "Բբ", "Б", + "Գգ", "Г", + "Դդ", "Д", + "Եե", "Е", + "Զզ", "З", +}, +{ + "Էէ", "Э", + "Ըը", "Ы", + "Թթ", "Тh", + "Ժժ", "Ж", + "Իի", "И", + "Լլ", "Ль", +}, +{ + "Խխ", "Х", + "Ծծ", "Ц", + "Կկ", "K", + "Հհ", "h", + "Ձձ", "Дз", + "Ղղ", "Гг", +}, +{ + "Ճճ", "Ч", + "Մմ", "М", + "Յյ", "Й", + "Նն", "Н", + "Շշ", "Ш", + "Ոո", "О", +}, +{ + "Չչ", "Ч", + "Պպ", "П", + "Ջջ", "Дж", + "Ռռ", "Рр", + "Սս", "С", + "Վվ", "В", +}, +{ + "Տտ", "Т", + "Րր", "Р", + "Ցց", "Цh", + "Ու", "У", + "Փփ", "Пh", + "Քք", "Kh", +}, +{ + "և", "Ев", + "Oo", "О", + "Ֆֆ", "Ф", +} +} + +function on_resume() + ui:show_table(tab) +end -- 2.43.0 From d66a798a99a58ad420e22397ba6e1d162ce60941 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 13 Jun 2023 11:12:21 +0400 Subject: [PATCH 026/204] Add monitor-lite widget --- community/monitor-lite-widget.lua | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 community/monitor-lite-widget.lua diff --git a/community/monitor-lite-widget.lua b/community/monitor-lite-widget.lua new file mode 100644 index 0000000..616e978 --- /dev/null +++ b/community/monitor-lite-widget.lua @@ -0,0 +1,40 @@ +-- name = "Monitor" +-- description = "One line monitor widget" +-- type = "widget" +-- foldable = "false" +-- author = "Evgeny Zobnin (zobnin@gmail.com)" +-- version = "1.0" + +local fmt = require "fmt" +local good_color = aio:colors().progress_good +local bad_color = aio:colors().progress_bad + +function on_tick(n) + -- Update every ten seconds + if n % 10 == 0 then + update() + end +end + +function update() + local batt_percent = system:battery_info().percent + local is_charging = system:battery_info().charging + local mem_total = system:system_info().mem_total + local mem_available = system:system_info().mem_available + local storage_total = system:system_info().storage_total + local storage_available = system:system_info().storage_available + + if (is_charging) then + batt_percent = fmt.colored(batt_percent.."%", good_color) + elseif (batt_percent <= 15) then + batt_percent = fmt.colored(batt_percent.."%", bad_color) + else + batt_percent = batt_percent.."%" + end + + ui:show_text( + "BATT: "..batt_percent..fmt.space(4).. + "RAM: "..mem_available..fmt.space(4).. + "NAND: "..storage_available + ) +end -- 2.43.0 From c02e94530979c413df557770492177fb00594429 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 14 Jun 2023 20:02:27 +0400 Subject: [PATCH 027/204] Add url widget --- samples/url-widget.lua | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 samples/url-widget.lua diff --git a/samples/url-widget.lua b/samples/url-widget.lua new file mode 100644 index 0000000..74eeecd --- /dev/null +++ b/samples/url-widget.lua @@ -0,0 +1,9 @@ +local url = "https://aiolauncher.app" + +function on_resume() + ui:show_text("Click me") +end + +function on_click() + system:open_browser(url) +end -- 2.43.0 From ae15d0e730f399963b578cd82b9ae6496c309381 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 30 Jun 2023 13:00:26 +0400 Subject: [PATCH 028/204] Update utils.lua --- lib/utils.lua | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/utils.lua b/lib/utils.lua index 38c5b52..f2f74a2 100644 --- a/lib/utils.lua +++ b/lib/utils.lua @@ -45,10 +45,38 @@ function get_key(tab, val) return index end end - + return 0 end +function concat_tables(t1, t2) + for _,v in ipairs(t2) do + table.insert(t1, v) + end +end + +function serialize_table(tab, ind) + ind = ind and (ind .. " ") or " " + local nl = "\n" + local str = "{" .. nl + for k, v in pairs(tab) do + local pr = (type(k)=="string") and ("[\"" .. k .. "\"] = ") or "" + str = str .. ind .. pr + if type(v) == "table" then + str = str .. serialize(v, ind) .. "," + elseif type(v) == "string" then + str = str .. "\"" .. tostring(v) .. "\"," + elseif type(v) == "number" or type(v) == "boolean" then + str = str .. tostring(v) .. "," + else + str = str .. "[[" .. tostring(v) .. "]]," + end + end + str = str:gsub(".$","") + str = str .. nl .. ind .. "}" + return str +end + function round(x, n) local n = math.pow(10, n or 0) local x = x * n @@ -66,3 +94,4 @@ function use(module, ...) end end + -- 2.43.0 From 55aad881e2134ac7d170da8d1a2c13de525abd83 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 30 Jun 2023 13:09:07 +0400 Subject: [PATCH 029/204] Update inspiration quotes widget --- main/inspiration-quotes-widget.lua | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/main/inspiration-quotes-widget.lua b/main/inspiration-quotes-widget.lua index 8c8c776..0297b24 100644 --- a/main/inspiration-quotes-widget.lua +++ b/main/inspiration-quotes-widget.lua @@ -1,24 +1,28 @@ -- name = "Inspiration quotes" --- description = "inspiration.goprogram.ai" --- data_source = "inspiration.goprogram.ai" +-- description = "ZenQuotes.io" +-- data_source = "https://zenquotes.io/" -- type = "widget" -- author = "Evgeny Zobnin (zobnin@gmail.com)" --- version = "1.0" +-- version = "2.0" -- foldable = "false" +local json = require "json" + function on_alarm() - http:get("https://inspiration.goprogram.ai/") + http:get("https://zenquotes.io/api/random") end -function on_network_result(result) - quote = ajson:get_value(result, "object string:quote") - author = ajson:get_value(result, "object string:author") +function on_network_result(result, code) + if code >= 200 and code < 299 then + res = json.decode(result) - ui:show_lines({ quote }, { author }) + ui:show_lines({ res[1].q }, { res[1].a }) + end end function on_click() - if quote ~= nil then - system:copy_to_clipboard(quote) + if res ~= nil then + system:to_clipboard(res[1].q.." - "..res[1].a) end end + -- 2.43.0 From 082df0cd09ac9d5b2c52fcbb1c686c1b85091b15 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 30 Jun 2023 13:09:46 +0400 Subject: [PATCH 030/204] update zip --- scripts.md5 | 2 +- scripts.zip | Bin 19788 -> 19821 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts.md5 b/scripts.md5 index 57f2b7a..c54d2ee 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -036867fef274dcbf6103cd73adb65e47 +8edd7e6979e2f1009a2dd9bdc7b7ee39 diff --git a/scripts.zip b/scripts.zip index 05a0e3737f822054236d1f69f9b831bdda3dde34..97ce358a621a277c9d7fa96f5c9e9c2a316475f4 100644 GIT binary patch delta 1752 zcmZ8idpOi-8~)7+AI%I3V+J!rDu#%55wrtp8b6U(_yYF?q?{i=8`&`fU-q(FS_tSF~^8PAB zVh_^;OKTkaAe*sH2dejEd* zqc*o7Sqp%`-@pK1>o{4om-mB>cIM(r?&o)0O;OQimj1;k75 z@~4NL%j56Yxs{grEs6rk=o|Z!#QWGaZU(_=r;&zZX@fitKEek_qVKHugTV_S>s5Z| z1AD@Xr0ms?GYO_!Jhijb7zho@zs2UX>!l4bvA?UwY99?RY7@%+8!{8S^z2Sb-EEx8 znlK6G>*1~Yzro!{)W>6Q>My!rN5nn%X))@rrEg1|-JrV#Uj}7EO9QH}yolIw^&N|A zT|AEc88XicHHln);C&;T%#Tg{uUe2I3so+~o}7CfIEr`TqNfdiu|!RG4Ogs!4Toxn z%paZ}T}VX)-&?j(#u&>o&06Fqb8r_!M=*KBb609Af2B0x{k&js@E{ul&gu}iblI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LyCU=FW^eVdx~i5K(q;aWp7CbO@3i*UGvkR7+*ps;Clrqy z_jm)3Xr%ntsAzcbLR;_oPwZA~8mMB{&G&VDlbiB}%dT3}EL7iE;J+Wt*tir-TIx%+ zFEPt{-!Pj-JYH~`!E2?CqD>4HCpiH!>7AmX#~oo4IUO&!vIkP@f}g67+6k;bB6|!( zfBvHstUB0^k9pZKvd`&E529hXwSL*!xP@KPnVwMyFSdX3s4Nrhf4nBsuh9|c2%l7O zZWKg_7B3JU26^eN=1www)fe}m;kM|G_cYtm72oCAHJkNJo?(J|EbRR1#agr18;cPM zc-^Yop)d3g=H@+6di+MWUeOuy*Bza+rU7F<%Z+&i-1WAjaSAvysny9syi6(;B@d4R zuYFRV%#GS*Y12U5KxpUGJJOkuVlR{R_NR%|ktP2Xaf99jCHTgXWeG%^&|QOCEyYaPw#_(hY-t9>8S4;OgLvnbmf$8k+a+z*TBrz(5C)4KwZTZb9!!b`Ks5{= zd_bo{XEeYC`d4r@8~}h+Iu`VEB18CKv6BaM84s>Fu^~@DrZXF21Kx2alRl#d3IH&G zCa^U&Sr3#Y%8dXZn&Th%&7}yF&=8Z*fB@6rNM8>Y0)TA-1~gz0Asyh?3@^w{u%6)q z8#w}idX{+5%w?bc*28*&C_0OqnF2R|2<&HxzXrox^uQ^X{h-iA3vvs5=Hd-ufnT~( K6o@CcuKyRv==`Vv -- 2.43.0 From 92f6e0de16af61309ebcd81ccc4b44a5788dd1b4 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 14 Jul 2023 21:18:05 +0400 Subject: [PATCH 031/204] Add new drawer scripts --- community/actions-menu.lua | 26 ++++++++ main/calendar-menu.lua | 39 ++++++++++++ main/contacts-menu.lua | 51 ++++++++++++++++ main/tasks-menu.lua | 114 +++++++++++++++++++++++++++++++++++ samples/bad-script.lua | 2 + samples/bad-script0.lua | 2 + samples/bad-script2.lua | 2 + samples/bad-script3.lua | 2 + samples/bad-script4.lua | 2 + samples/bad-script5.lua | 2 + samples/bad-script6.lua | 2 + samples/bad-script7.lua | 2 + samples/bad-script8.lua | 2 + samples/calendar-sample.lua | 2 +- samples/calendar-sample3.lua | 7 +++ samples/drawer-sample.lua | 46 ++++++++++++++ samples/drawer-sample3.lua | 25 ++++++++ samples/drawer-sample4.lua | 26 ++++++++ samples/drawer-test.lua | 8 +++ samples/notes-tests.lua | 73 ++++++++++++++++++++++ samples/search-widget.lua | 13 ++++ samples/tasks-tests.lua | 73 ++++++++++++++++++++++ 22 files changed, 520 insertions(+), 1 deletion(-) create mode 100644 community/actions-menu.lua create mode 100644 main/calendar-menu.lua create mode 100644 main/contacts-menu.lua create mode 100644 main/tasks-menu.lua create mode 100644 samples/calendar-sample3.lua create mode 100644 samples/drawer-sample.lua create mode 100644 samples/drawer-sample3.lua create mode 100644 samples/drawer-sample4.lua create mode 100644 samples/drawer-test.lua create mode 100644 samples/notes-tests.lua create mode 100644 samples/search-widget.lua create mode 100644 samples/tasks-tests.lua diff --git a/community/actions-menu.lua b/community/actions-menu.lua new file mode 100644 index 0000000..70467a4 --- /dev/null +++ b/community/actions-menu.lua @@ -0,0 +1,26 @@ +-- name = "Actions menu" +-- name_id = "actions" +-- description = "Shows aio launcher actions" +-- type = "drawer" +-- aio_version = "4.7.99" +-- author = "Evgeny Zobnin" +-- version = "1.0" + +function on_drawer_open() + actions = aio:actions() + labels = map(actions, function(it) return it.label end) + drawer:show_list(labels) +end + +function on_click(idx) + aio:do_action(actions[idx].name) + drawer:close() +end + +function map(tbl, f) + local ret = {} + for k,v in pairs(tbl) do + ret[k] = f(v) + end + return ret +end diff --git a/main/calendar-menu.lua b/main/calendar-menu.lua new file mode 100644 index 0000000..4fb20da --- /dev/null +++ b/main/calendar-menu.lua @@ -0,0 +1,39 @@ +-- name = "Calendar menu" +-- name_id = "calendar" +-- description = "Shows events from system calendar" +-- type = "drawer" +-- aio_version = "4.7.99" +-- author = "Evgeny Zobnin" +-- version = "1.0" + +local fmt = require "fmt" + +local events = {} + +function on_drawer_open() + events = calendar:events() + + lines = map(events, function(it) + local date = fmt.colored(os.date("%d.%m", it.begin), it.color) + return date..fmt.space(4)..it.title + end) + + drawer:show_ext_list(lines) +end + +function on_click(idx) + calendar:show_event_dialog(events[idx].id) +end + +function on_long_click(idx) + calendar:open_event(events[idx].id) +end + +function map(tbl, f) + local ret = {} + for k,v in pairs(tbl) do + ret[k] = f(v) + end + return ret +end + diff --git a/main/contacts-menu.lua b/main/contacts-menu.lua new file mode 100644 index 0000000..37e44cd --- /dev/null +++ b/main/contacts-menu.lua @@ -0,0 +1,51 @@ +-- name = "Contacts menu" +-- name_id = "contacts" +-- description = "Shows phone contacts in the side menu" +-- type = "drawer" +-- aio_version = "4.7.99" +-- author = "Evgeny Zobnin" +-- version = "1.0" + +function on_drawer_open() + contacts = distinct_by_name( + sort_by_name(phone:contacts()) + ) + + names = map(contacts, function(it) return it.name end) + keys = map(contacts, function(it) return it.lookup_key end) + + phone:request_icons(keys) +end + +function on_icons_ready(icons) + drawer:show_list(names, icons, nil, true) +end + +function on_click(idx) + phone:show_contact_dialog(contacts[idx].lookup_key) +end + +function map(tbl, f) + local ret = {} + for k,v in pairs(tbl) do + ret[k] = f(v) + end + return ret +end + +function sort_by_name(tbl) + table.sort(tbl, function(a,b) return a.name:lower() < b.name:lower() end) + return tbl +end + +function distinct_by_name(tbl) + local ret = {} + local names = {} + for _, contact in ipairs(tbl) do + if not names[contact.name] then + table.insert(ret, contact) + end + names[contact.name] = true + end + return ret +end diff --git a/main/tasks-menu.lua b/main/tasks-menu.lua new file mode 100644 index 0000000..934a49c --- /dev/null +++ b/main/tasks-menu.lua @@ -0,0 +1,114 @@ +-- name = "Notes & tasks menu" +-- name_id = "notes" +-- description = "Shows tasks in the side menu" +-- type = "drawer" +-- aio_version = "4.7.99" +-- author = "Evgeny Zobnin" +-- version = "1.0" + +local fmt = require "fmt" +local prefs = require "prefs" + +local primary_color = aio:colors().primary_color +local secondary_color = aio:colors().secondary_color + +local bottom_buttons = { + "fa:note_sticky", -- notes tab + "fa:list-check", -- tasks tab + "fa:pipe", -- separator + "fa:note_medical", -- new note button + "fa:square_plus" -- new task button +} + +local notes_list = {} +local tasks_list = {} + +if prefs.curr_tab == nil then + prefs.curr_tab = 1 +end + +function on_drawer_open() + drawer:add_buttons(bottom_buttons, prefs.curr_tab) + + if prefs.curr_tab == 1 then + notes:load() + else + tasks:load() + end +end + +function on_tasks_loaded(new_tasks) + tasks_list = new_tasks + local texts = map(tasks_list, task_to_text) + drawer:show_ext_list(texts) +end + +function on_notes_loaded(new_notes) + notes_list = new_notes + local texts = map(notes_list, note_to_text) + drawer:show_ext_list(texts) +end + +function note_to_text(it) + if it.text == "test note" then + test_note = it + end + + if it.color ~= 6 then + return fmt.colored(it.text, notes:colors()[it.color]) + else + return it.text + end +end + +function task_to_text(it) + local text = "" + local date_str = os.date("%b, %d, %H:%M", it.due_date) + + if it.completed_date > 0 then + text = fmt.strike(it.text) + elseif it.due_date < os.time() then + text = fmt.bold(fmt.red(it.text)) + elseif it.is_today then + text = fmt.bold(it.text) + else + text = it.text + end + + return text.."
"..fmt.space(4)..fmt.small(date_str) +end + +function on_click(idx) + if prefs.curr_tab == 1 then + on_note_click(idx) + else + on_task_click(idx) + end +end + +function on_note_click(idx) + notes:show_editor(notes_list[idx].id) +end + +function on_task_click(idx) + tasks:show_editor(tasks_list[idx].id) +end + +function on_button_click(idx) + if idx < 3 then + prefs.curr_tab = idx + on_drawer_open() + elseif idx == 4 then + notes:show_editor() + elseif idx == 5 then + tasks:show_editor() + end +end + +function map(tbl, f) + local ret = {} + for k,v in pairs(tbl) do + ret[k] = f(v) + end + return ret +end diff --git a/samples/bad-script.lua b/samples/bad-script.lua index 85cde84..3e8c031 100644 --- a/samples/bad-script.lua +++ b/samples/bad-script.lua @@ -1,3 +1,5 @@ +-- testing = "true" + function on_resume() ui:show_text("Click to freeze launcher") end diff --git a/samples/bad-script0.lua b/samples/bad-script0.lua index d2bfdf2..9cc626f 100644 --- a/samples/bad-script0.lua +++ b/samples/bad-script0.lua @@ -1,3 +1,5 @@ +-- testing = "true" + function on_resume() while true do end diff --git a/samples/bad-script2.lua b/samples/bad-script2.lua index e38da0e..08f8214 100644 --- a/samples/bad-script2.lua +++ b/samples/bad-script2.lua @@ -1,3 +1,5 @@ +-- testing = "true" + function on_resume() while true do ui:show_text("Haha") diff --git a/samples/bad-script3.lua b/samples/bad-script3.lua index 102216e..a079711 100644 --- a/samples/bad-script3.lua +++ b/samples/bad-script3.lua @@ -1,2 +1,4 @@ +-- testing = "true" + ui:show_toast("Hello") diff --git a/samples/bad-script4.lua b/samples/bad-script4.lua index bb7bf92..1d01d92 100644 --- a/samples/bad-script4.lua +++ b/samples/bad-script4.lua @@ -1,3 +1,5 @@ +-- testing = "true" + function on_tick() while true do ui:show_text("bad") diff --git a/samples/bad-script5.lua b/samples/bad-script5.lua index c9ca73c..8a7044b 100644 --- a/samples/bad-script5.lua +++ b/samples/bad-script5.lua @@ -1,3 +1,5 @@ +-- testing = "true" + function on_resume() ui:show_aaa() end diff --git a/samples/bad-script6.lua b/samples/bad-script6.lua index 4d7a22f..4c5ec50 100644 --- a/samples/bad-script6.lua +++ b/samples/bad-script6.lua @@ -1,3 +1,5 @@ +-- testing = "true" + function on_resume() ui:show_text("Tap to halt") end diff --git a/samples/bad-script7.lua b/samples/bad-script7.lua index 97906ed..8c05c52 100644 --- a/samples/bad-script7.lua +++ b/samples/bad-script7.lua @@ -1,3 +1,5 @@ +-- testing = "true" + function on_resume() package.path = ";;" end diff --git a/samples/bad-script8.lua b/samples/bad-script8.lua index d775744..f04a31f 100644 --- a/samples/bad-script8.lua +++ b/samples/bad-script8.lua @@ -1,3 +1,5 @@ +-- testing = "true" + function on_resume() for i = 1, 15 do system:copy_to_clipboard("aaa") diff --git a/samples/calendar-sample.lua b/samples/calendar-sample.lua index 546c68c..5a66d9a 100644 --- a/samples/calendar-sample.lua +++ b/samples/calendar-sample.lua @@ -13,5 +13,5 @@ function on_resume() end function on_click(idx) - calendar:show_event_dialog(events[idx].id) + calendar:show_event_dialog(events[idx]) end diff --git a/samples/calendar-sample3.lua b/samples/calendar-sample3.lua new file mode 100644 index 0000000..3f4bc16 --- /dev/null +++ b/samples/calendar-sample3.lua @@ -0,0 +1,7 @@ +function on_resume() + ui:show_text("Tap to create new event") +end + +function on_click(idx) + calendar:open_new_event(os.time(), os.time() + 3600) +end diff --git a/samples/drawer-sample.lua b/samples/drawer-sample.lua new file mode 100644 index 0000000..96c3e10 --- /dev/null +++ b/samples/drawer-sample.lua @@ -0,0 +1,46 @@ +-- name = "Drawer Sample" +-- type = "drawer" +-- testing = "true" + +local fmt = require "fmt" +local list = {} +local cur_tab = 1 + +function on_drawer_open() + if cur_tab == 1 then + show_list1() + else + show_list2() + end + + drawer:add_buttons({"fa:circle-1", "fa:circle-2"}, cur_tab) +end + +function show_list1() + list = { "First line", fmt.bold("Second line"), fmt.red("Third line") } + -- optional + local icons = { "fa:circle-1", "fa:circle-2", "fa:circle-3" } + -- optional + local badges = { "Wow", "New", "11" } + + drawer:show_list(list, icons, badges) +end + +function show_list2() + list = { + "You can display long text as side-menu items.", + "This can be used, for example, to display a list of messages.", + "Even if you don't use this output method, I think it's cool.", + } + + drawer:show_ext_list(list) +end + +function on_click(idx) + debug:toast(list[idx].." clicked") +end + +function on_button_click(idx) + cur_tab = idx + on_drawer_open() +end diff --git a/samples/drawer-sample3.lua b/samples/drawer-sample3.lua new file mode 100644 index 0000000..30083ee --- /dev/null +++ b/samples/drawer-sample3.lua @@ -0,0 +1,25 @@ +-- name = "Drawer Sample #3" +-- type = "drawer" +-- testing = "true" + +local list = { + "abc", + "launch_count", + "launch_time", + "install_time", + "appbox", + "categories", + "close", +} + +function on_drawer_open() + drawer:show_list(list) +end + +function on_click(idx) + if list[idx] == "close" then + drawer:close() + else + drawer:change_view(list[idx]) + end +end diff --git a/samples/drawer-sample4.lua b/samples/drawer-sample4.lua new file mode 100644 index 0000000..7cdc30a --- /dev/null +++ b/samples/drawer-sample4.lua @@ -0,0 +1,26 @@ +-- name = "Drawer sample #4" +-- type = "drawer" +-- testing = "true" + +function on_drawer_open() + pkgs = apps:list() + apps:request_icons(pkgs) +end + +function on_icons_ready(icons) + names = map(pkgs, function(it) return apps:name(it) end) + drawer:show_list(names, icons, nil, true) +end + +function on_click(idx) + apps:launch(pkgs[idx]) +end + +function map(tbl, f) + local ret = {} + for k,v in pairs(tbl) do + ret[k] = f(v) + end + return ret +end + diff --git a/samples/drawer-test.lua b/samples/drawer-test.lua new file mode 100644 index 0000000..f9668d7 --- /dev/null +++ b/samples/drawer-test.lua @@ -0,0 +1,8 @@ +-- name = "Drawer test" +-- type = "drawer" +-- testing = "true" + +function on_drawer_open() + drawer:show_list{ "Empty" } + debug:toast("on_drawer_open() called!") +end diff --git a/samples/notes-tests.lua b/samples/notes-tests.lua new file mode 100644 index 0000000..7e7ee9f --- /dev/null +++ b/samples/notes-tests.lua @@ -0,0 +1,73 @@ +-- name = "Notes tests" +-- type = "drawer" +-- aio_version = "4.7.99" +-- author = "Evgeny Zobnin" +-- version = "1.0" +-- testing = "true" + +local fmt = require "fmt" +local notes_list = {} +local test_note = {} + +function on_drawer_open() + refresh() +end + +function refresh() + notes:load() +end + +function on_notes_loaded(new_notes) + notes_list = new_notes + local texts = map(notes_list, note_to_text) + table.insert(texts, fmt.italic("Show new note dialog")) + table.insert(texts, fmt.italic("Add test note")) + table.insert(texts, fmt.italic("Change test note")) + drawer:show_ext_list(texts) +end + +function on_click(idx) + if idx == #notes_list+1 then + notes:show_editor() + drawer:close() + elseif idx == #notes_list+2 then + notes:add{text = "test note"} + refresh() + elseif idx == #notes_list+3 then + test_note.text = "test note (changed)" + test_note.color = 1 + test_note.position = test_note.position-3 + notes:save(test_note) + refresh() + else + notes:show_editor(notes_list[idx].id) + drawer:close() + end +end + +function on_long_click(idx) + if idx <= #notes_list then + notes:remove(notes_list[idx].id) + refresh() + end +end + +function note_to_text(it) + if it.text == "test note" then + test_note = it + end + + if it.color ~= 6 then + return fmt.colored(it.text, notes:colors()[it.color]) + else + return it.text + end +end + +function map(tbl, f) + local ret = {} + for k,v in pairs(tbl) do + ret[k] = f(v) + end + return ret +end diff --git a/samples/search-widget.lua b/samples/search-widget.lua new file mode 100644 index 0000000..8ed9c6d --- /dev/null +++ b/samples/search-widget.lua @@ -0,0 +1,13 @@ +-- name = "Search" +-- description = "Simple widget to open search screen" +-- type = "widget" +-- author = "Evgeny Zobnin (zobnin@gmail.com)" +-- version = "1.0" + +function on_resume() + ui:show_text("Open search") +end + +function on_click(idx) + aio:do_action("search") +end diff --git a/samples/tasks-tests.lua b/samples/tasks-tests.lua new file mode 100644 index 0000000..7b2290f --- /dev/null +++ b/samples/tasks-tests.lua @@ -0,0 +1,73 @@ +-- name = "Tasks tests" +-- type = "drawer" +-- aio_version = "4.7.99" +-- author = "Evgeny Zobnin" +-- version = "1.0" +-- testing = "true" + +local fmt = require "fmt" +local tasks_list = {} +local test_task = {} + +function on_drawer_open() + refresh() +end + +function refresh() + tasks:load() +end + +function on_tasks_loaded(new_tasks) + tasks_list = new_tasks + local texts = map(tasks_list, task_to_text) + table.insert(texts, fmt.italic("Show new task dialog")) + table.insert(texts, fmt.italic("Add test task")) + table.insert(texts, fmt.italic("Change test task")) + drawer:show_ext_list(texts) +end + +function on_click(idx) + if idx == #tasks_list+1 then + tasks:show_editor() + elseif idx == #tasks_list+2 then + tasks:add{text = "test task"} + refresh() + elseif idx == #tasks_list+3 then + test_task.text = "test task (changed)" + tasks:save(test_task) + refresh() + else + tasks:show_editor(tasks_list[idx].id) + end +end + +function on_long_click(idx) + if idx <= #tasks_list then + tasks:remove(tasks_list[idx].id) + refresh() + end +end + +function task_to_text(it) + if it.text == "test task" then + test_task = it + end + + if it.completed_date > 0 then + return fmt.strike(it.text) + elseif it.due_date < os.time() then + return fmt.bold(fmt.red(it.text)) + elseif it.is_today then + return fmt.bold(it.text) + else + return it.text + end +end + +function map(tbl, f) + local ret = {} + for k,v in pairs(tbl) do + ret[k] = f(v) + end + return ret +end -- 2.43.0 From 73dce8ba03cffdd79f9c83194441a8ce385f57ec Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 14 Jul 2023 21:20:08 +0400 Subject: [PATCH 032/204] Remove twitter widget from Widgets switcher --- main/widgets-on-off.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main/widgets-on-off.lua b/main/widgets-on-off.lua index d6ff2de..8f31960 100644 --- a/main/widgets-on-off.lua +++ b/main/widgets-on-off.lua @@ -7,11 +7,11 @@ --constants-- -local widgets = {"weather","weatheronly","clock","alarm","worldclock","monitor","traffic","player","apps","appbox","applist","contacts","notify","dialogs","dialer","timer","stopwatch","mail","notes","tasks", "health", "feed","telegram","twitter","calendar","exchange","finance","bitcoin","control","recorder","calculator","empty","bluetooth","map","remote"} +local widgets = {"weather","weatheronly","clock","alarm","worldclock","monitor","traffic","player","apps","appbox","applist","contacts","notify","dialogs","dialer","timer","stopwatch","mail","notes","tasks", "health", "feed","telegram","calendar","exchange","finance","bitcoin","control","recorder","calculator","empty","bluetooth","map","remote"} -local icons = {"fa:user-clock","fa:sun-cloud","fa:clock","fa:alarm-clock","fa:business-time","fa:network-wired","fa:exchange","fa:play-circle","fa:robot","fa:th","fa:list","fa:address-card","fa:bell","fa:comment-alt-minus","fa:phone-alt","fa:chess-clock","fa:stopwatch","fa:at","fa:sticky-note","fa:calendar-check", "fa:heart-pulse", "fa:rss-square","fa:paper-plane","fa:dove","fa:calendar-alt","fa:euro-sign","fa:chart-line","fa:coins","fa:wifi","fa:microphone-alt","fa:calculator-alt","fa:eraser","fa:head-side-headphones","fa:map-marked-alt","fa:user-tag"} +local icons = {"fa:user-clock","fa:sun-cloud","fa:clock","fa:alarm-clock","fa:business-time","fa:network-wired","fa:exchange","fa:play-circle","fa:robot","fa:th","fa:list","fa:address-card","fa:bell","fa:comment-alt-minus","fa:phone-alt","fa:chess-clock","fa:stopwatch","fa:at","fa:sticky-note","fa:calendar-check", "fa:heart-pulse", "fa:rss-square","fa:paper-plane","fa:calendar-alt","fa:euro-sign","fa:chart-line","fa:coins","fa:wifi","fa:microphone-alt","fa:calculator-alt","fa:eraser","fa:head-side-headphones","fa:map-marked-alt","fa:user-tag"} -local names = {"Clock & weather","Weather","Clock","Alarm","Worldclock","Monitor","Traffic","Player","Frequent apps","My apps","App list","Contacts","Notify","Dialogs","Dialer","Timer","Stopwatch","Mail","Notes","Tasks", "Health", "Feed","Telegram","Twitter","Calendar","Exchange","Finance","Bitcoin","Control panel","Recorder","Calculator","Empty widget","Bluetooth","Map","User widget"} +local names = {"Clock & weather","Weather","Clock","Alarm","Worldclock","Monitor","Traffic","Player","Frequent apps","My apps","App list","Contacts","Notify","Dialogs","Dialer","Timer","Stopwatch","Mail","Notes","Tasks", "Health", "Feed","Telegram","Calendar","Exchange","Finance","Bitcoin","Control panel","Recorder","Calculator","Empty widget","Bluetooth","Map","User widget"} --variables-- -- 2.43.0 From 7aa368dacae1da9e1f0120a8f4e90662e75737ae Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 15 Jul 2023 13:51:26 +0400 Subject: [PATCH 033/204] add permission checks to main widgets --- main/calendar-menu.lua | 12 ++++++++++++ main/calendar.lua | 14 ++++++++++++++ main/contacts-menu.lua | 13 +++++++++++++ 3 files changed, 39 insertions(+) diff --git a/main/calendar-menu.lua b/main/calendar-menu.lua index 4fb20da..af4f3b8 100644 --- a/main/calendar-menu.lua +++ b/main/calendar-menu.lua @@ -8,11 +8,19 @@ local fmt = require "fmt" +local have_permission = false local events = {} function on_drawer_open() events = calendar:events() + if events == "permission_error" then + calendar:request_permission() + return + end + + have_permission = true + lines = map(events, function(it) local date = fmt.colored(os.date("%d.%m", it.begin), it.color) return date..fmt.space(4)..it.title @@ -22,10 +30,14 @@ function on_drawer_open() end function on_click(idx) + if not have_permission then return end + calendar:show_event_dialog(events[idx].id) end function on_long_click(idx) + if not have_permission then return end + calendar:open_event(events[idx].id) end diff --git a/main/calendar.lua b/main/calendar.lua index 59aaa3e..e0a6efa 100644 --- a/main/calendar.lua +++ b/main/calendar.lua @@ -15,12 +15,20 @@ local month = os.date("%m"):gsub("^0","") local day = os.date("%d"):gsub("^0","") function on_resume() + if widget_type == "text" then + return + end --ui:set_folding_flag(true) ui:show_table(table_to_tables(tab,8),0, true, line) widget_type = "table" end function on_alarm() + if calendar:events(0,0) == "permission_error" then + widget_type = "text" + ui:show_text("Click to grant permission") + return + end if next(settings:get()) == nil then settings:set(get_all_cals()[2]) end @@ -72,9 +80,15 @@ function on_click(i) widget_type = "table" ui:show_table(table_to_tables(tab,8),0, true, line) end + elseif widget_type == "text" then + calendar:request_permission() end end +function on_permission_granted() + on_alarm() +end + function on_dialog_action(data) if data == -1 then events = {} diff --git a/main/contacts-menu.lua b/main/contacts-menu.lua index 37e44cd..36013e6 100644 --- a/main/contacts-menu.lua +++ b/main/contacts-menu.lua @@ -6,7 +6,18 @@ -- author = "Evgeny Zobnin" -- version = "1.0" +local have_permission = false + function on_drawer_open() + local raw_contacts = phone:contacts() + + if raw_contacts == "permission_error" then + phone:request_permission() + return + end + + have_permission = true + contacts = distinct_by_name( sort_by_name(phone:contacts()) ) @@ -22,6 +33,8 @@ function on_icons_ready(icons) end function on_click(idx) + if not have_permission then return end + phone:show_contact_dialog(contacts[idx].lookup_key) end -- 2.43.0 From b35fd3292c4087be5748b788cf2cae5d3808322f Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 15 Jul 2023 15:39:20 +0400 Subject: [PATCH 034/204] Update utils --- README.md | 12 ++-- lib/utils.lua | 184 ++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 188 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ced6439..36a1760 100644 --- a/README.md +++ b/README.md @@ -557,10 +557,13 @@ The standard Lua API is extended with the following features: * `string:split(delimeter)` - splits the string using the specified delimiter and returns a table; * `string:replace(regexp, string)` - replaces the text found by the regular expression with another text; * `slice(table, start, end)` - returns the part of the table starting with the `start` index and ending with `end` index; -* `get_index(table, value)` - returns the index of the table element; -* `get_key(table, value)` - returns the key of the table element; -* `concat_tables(table1, table2)` - adds elements from array table `table2` to `table1`; +* `index(table, value)` - returns the index of the table element; +* `key(table, value)` - returns the key of the table element; +* `concat(table1, table2)` - adds elements from array table `table2` to `table1`; +* `reverse(table)` - returns a table in which the elements follow in reverse order; +* `serialize(table)` - serializes the table into executable Lua code; * `round(x, n)` - rounds the number; +* `map(function, table)`, `filter(function, table)`, `head(table)`, `tail(table)`, `reduce(function, table)` - several convenience functional utilities form Haskell, Python etc. AIO Launcher also includes: @@ -620,7 +623,8 @@ Some tips on writing and debugging scripts: * The most convenient way to upload scripts to your smartphone is to use the `install-scripts.sh` script from this repository. This is a sh script for UNIX systems which loads all the scripts from the repository onto the (virtual) memory card of the smartphone using ADB. You can edit it to your liking. * The easiest way to reload an updated widget script is to swipe the widget to the right and then press the "reload" button. The search scripts will be reloaded automatically next time you open the search window. * Since version 4.3.0 AIO Launcher supports widget scripts hot reloading. To enable it, go to AIO Settings -> About and click on the version number 7 times. Then open AIO Settings -> Testing and enable the option "Hot reload scripts on resume". Now when you change the script, it will be automatically reloaded when you return to the desktop. -* Since version 4.4.2 AIO Launcher includes `debug` module with methods: `debug:log(text)`, `debug:toast(text)` and `debug:dialog(text)`. +* Since version 4.4.2 AIO Launcher includes `debug` module with methods: `debug:log(text)`, `debug:toast(text)` and `debug:dialog(text)`; +* Since version 4.8.0 you can use `--testing = "true"` meta tag. In this case, launcher will gray out the script and place it at the end of the list in the side menu. # Contribution diff --git a/lib/utils.lua b/lib/utils.lua index f2f74a2..0918600 100644 --- a/lib/utils.lua +++ b/lib/utils.lua @@ -29,7 +29,7 @@ function slice(tbl, s, e) return new end -function get_index(tab, val) +function index(tab, val) for index, value in ipairs(tab) do if value == val then return index @@ -39,7 +39,12 @@ function get_index(tab, val) return 0 end -function get_key(tab, val) +-- Deprecated +function get_index(tab, val) + return index(tab, val) +end + +function key(tab, val) for index, value in pairs(tab) do if value == val then return index @@ -49,13 +54,30 @@ function get_key(tab, val) return 0 end -function concat_tables(t1, t2) +-- Deprecated +function get_key(tab, val) + return key(tab, val) +end + +function concat(t1, t2) for _,v in ipairs(t2) do table.insert(t1, v) end end -function serialize_table(tab, ind) +-- Deprecated +function concat_tables(t1, t2) + concat(t1, t2) +end + +function reverse(tab) + for i = 1, math.floor(#tab/2) do + tab[i], tab[#tab-i+1] = tab[#tab-i+1], tab[i] + end + return tab +end + +function serialize(tab, ind) ind = ind and (ind .. " ") or " " local nl = "\n" local str = "{" .. nl @@ -94,4 +116,158 @@ function use(module, ...) end end +-- Functional Library +-- +-- @file functional.lua +-- @author Shimomura Ikkei +-- @date 2005/05/18 +-- +-- @brief porting several convenience functional utilities form Haskell,Python etc.. +-- map(function, table) +-- e.g: map(double, {1,2,3}) -> {2,4,6} +function map(func, tbl) + local newtbl = {} + for i,v in pairs(tbl) do + newtbl[i] = func(v) + end + return newtbl +end + +-- filter(function, table) +-- e.g: filter(is_even, {1,2,3,4}) -> {2,4} +function filter(func, tbl) + local newtbl= {} + for i,v in pairs(tbl) do + if func(v) then + newtbl[i]=v + end + end + return newtbl +end + +-- head(table) +-- e.g: head({1,2,3}) -> 1 +function head(tbl) + return tbl[1] +end + +-- tail(table) +-- e.g: tail({1,2,3}) -> {2,3} +-- +-- XXX This is a BAD and ugly implementation. +-- should return the address to next porinter, like in C (arr+1) +function tail(tbl) + if table.getn(tbl) < 1 then + return nil + else + local newtbl = {} + local tblsize = table.getn(tbl) + local i = 2 + while (i <= tblsize) do + table.insert(newtbl, i-1, tbl[i]) + i = i + 1 + end + return newtbl + end +end + +-- foldr(function, default_value, table) +-- e.g: foldr(operator.mul, 1, {1,2,3,4,5}) -> 120 +function foldr(func, val, tbl) + for i,v in pairs(tbl) do + val = func(val, v) + end + return val +end + +-- reduce(function, table) +-- e.g: reduce(operator.add, {1,2,3,4}) -> 10 +function reduce(func, tbl) + return foldr(func, head(tbl), tail(tbl)) +end + +-- curry(f,g) +-- e.g: printf = curry(io.write, string.format) +-- -> function(...) return io.write(string.format(unpack(arg))) end +function curry(f,g) + return function (...) + return f(g(unpack(arg))) + end +end + +-- bind1(func, binding_value_for_1st) +-- bind2(func, binding_value_for_2nd) +-- @brief +-- Binding argument(s) and generate new function. +-- @see also STL's functional, Boost's Lambda, Combine, Bind. +-- @examples +-- local mul5 = bind1(operator.mul, 5) -- mul5(10) is 5 * 10 +-- local sub2 = bind2(operator.sub, 2) -- sub2(5) is 5 -2 +function bind1(func, val1) + return function (val2) + return func(val1, val2) + end +end +function bind2(func, val2) -- bind second argument. + return function (val1) + return func(val1, val2) + end +end + +-- is(checker_function, expected_value) +-- @brief +-- check function generator. return the function to return boolean, +-- if the condition was expected then true, else false. +-- @example +-- local is_table = is(type, "table") +-- local is_even = is(bind2(math.mod, 2), 1) +-- local is_odd = is(bind2(math.mod, 2), 0) +is = function(check, expected) + return function (...) + if (check(unpack(arg)) == expected) then + return true + else + return false + end + end +end + +-- operator table. +-- @see also python's operator module. +operator = { + mod = math.mod; + pow = math.pow; + add = function(n,m) return n + m end; + sub = function(n,m) return n - m end; + mul = function(n,m) return n * m end; + div = function(n,m) return n / m end; + gt = function(n,m) return n > m end; + lt = function(n,m) return n < m end; + eq = function(n,m) return n == m end; + le = function(n,m) return n <= m end; + ge = function(n,m) return n >= m end; + ne = function(n,m) return n ~= m end; + +} + +-- enumFromTo(from, to) +-- e.g: enumFromTo(1, 10) -> {1,2,3,4,5,6,7,8,9} +-- TODO How to lazy evaluate in Lua? (thinking with coroutine) +enumFromTo = function (from,to) + local newtbl = {} + local step = bind2(operator[(from < to) and "add" or "sub"], 1) + local val = from + while val <= to do + table.insert(newtbl, table.getn(newtbl)+1, val) + val = step(val) + end + return newtbl +end + +-- make function to take variant arguments, replace of a table. +-- this does not mean expand the arguments of function took, +-- it expand the function's spec: function(tbl) -> function(...) +function expand_args(func) + return function(...) return func(arg) end +end -- 2.43.0 From 081d8c41a185f01b9be7fdfe026674d765ae8528 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 15 Jul 2023 16:51:44 +0400 Subject: [PATCH 035/204] Reflect latest API changes in the README --- README.md | 151 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 121 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 36a1760..14ad92c 100644 --- a/README.md +++ b/README.md @@ -16,27 +16,17 @@ The type of script is determined by the line (meta tag) at the beginning of the # Changelog -* 4.0.0 - first version with scripts support; -* 4.1.0 - added `weather` and `cloud` modules; -* 4.1.3 - added `notify`, `files` and `utils` modules; -* 4.1.5 - extended `notify` module, added `folded_string` arg to `ui:show_lines`; -* 4.3.0 - search scripts support; -* 4.4.0 - markdown support; -* 4.4.1 - rich text editor support; -* 4.4.2 - added `fmt` and `html` utility modules; -* 4.4.4 - added `tasker` module; -* 4.4.6 - added `csv` module; -* 4.4.7 - added `intent` module; -* 4.5.0 - the `aio` module has been significantly expanded, also added `system:currency()` and `ui:show_list_dialog()`; -* 4.5.2 - added `anim` and `morph` packages, added `calendar:open_event()` function; -* 4.5.3 - removed get_ prefixes where they are not needed while maintaining backward compatibility; -* 4.5.5 - added `on_action` callback and `calendar:add_event` function; -* 4.5.6 - `aio:active_widgets()` now returns also widget `label`, added `checks` module; -* 4.5.7 - added "fold" and "unfold" actions to the `on_action` callback; -* 4.6.0 - added `system:request_location()` and `tasker:send_command()` functions; -* 4.7.0 - added `ui:build()` and functions to display search results in different formats; -* 4.7.1 - fontawesome updated to version 6.3.0; -* 4.7.4 - added `prefs` module, `settings` module is deprecated. +### 4.8.0 + +* Side menu scripts support; +* New modules: `tasks` and `notes`; +* The `ui:colors()` can be called as `aio:colors()`; +* The `apps` and `phone` modules now returns icons; +* The `apps` modules now returns also Android for Work and cloned apps; +* The `apps` module now allows you to sort apps by category; +* The `phone` and `calendar` modules now have functions for requesting access rights; +* Added `aio:actions()` function that returns a table of AIO Launcher actions; +* Added `calendar:open_new_event()` function that shows the system calendar with the new event. # Widget scripts @@ -78,6 +68,38 @@ If you want the script to respond only to search queries that have a word in the If you put such a tag at the beginning of your script, its `on_search()` function will only be called if a user types something like "youtube funny video" or "yt funny video". The prefix itself will be removed before being passed to the function. +# Side menu scripts + +With side menu scripts, you can display your own list in the menu. The script can be selected by pulling the menu down. + +The script starts with the following function: + +``` +on_drawer_open() + +``` + +In this function, you must prepare a list and display it using one of the following functions: + +``` +* ``drawer:show_list(lines, [icons], [badges], [show_alphabet])`` - shows lines, optionally you can specify a table of icons (in `fa:icon_name` format), a table of lines to be displayed in badges and pass a boolean value: whether to show the alphabet; +* ``drawer:show_ext_lines(lines, [max_lines)`` - shows multiline lines, optionally you can specify the maximum number of lines of each element (default is 5). + +``` + +The following functions are also available: + +``` +* ``drawer:add_buttons(icons, default_index)`` - shows icons at the bottom of the menu (in `fa:icon_name` format), `default_index` is the index of the selected icon; +* `drawer:clear()` - clears the list; +* `drawer:close()` - closes the menu; +* `drawer:change_view(name)` - switches the menu to another script or display style (argument: either script file name, `sortable` or `categories`). +``` + +Clicking on list items will call `on_click(index)`, long-clicking will call `on_long_click(index)`, clicking a bottom icon will call `on_button_click(index)`. + +The list output functions support HTML and Markdown (see User Interface section for details). + # API Reference ## User Interface @@ -94,8 +116,7 @@ _Available only in widget scripts._ * `ui:default_title()` - returns the standard widget title (set in the `name` metadata); * `ui:set_title()` - changes the title of the widget, should be called before the data display function (empty line - reset to the standard title); * `ui:set_folding_flag(boolean)` - sets the flag of the folded mode of the widget, the function should be called before the data display functions; -* `ui:folding_flag()` - returns folding flag; -* `ui:colors()` - returns table with current theme colors; +* `ui:folding_flag()` - returns folding flag. When you click on any element of the interface, the `on_click(number)` callback will be executed, where number is the ordinal number of the element. A long click calls `on_long_click(number)`. For example, if you use `ui:show_buttons` to show three buttons, then clicking the first button will call `on_click` with argument 1, the second with arguments 2, and so on. If there is only one element on the screen, the argument will always be equal to one and can be omitted. @@ -269,8 +290,10 @@ Intent table format (all fields are optional): * `aio:fold_widget(string, [boolean])` - fold/unfold widget (if you do not specify the second argument the state will be switched) (_available from: 4.5.0_); * `aio:is_widget_added(string)` - checks if the widget is added to the screen; * `aio:self_name()` - returns current script file name (_available from: 4.5.0_); +* `aio:send_message(value, [script_name])` - sends lua value to other script or scripts (_avaialble from: 4.5.0_); +* `ui:colors()` - returns table with current theme colors; * `aio:do_action(string)` - performs an AIO action ([more](https://aiolauncher.app/api.html)); -* `aio:send_message(value, [script_name])` - sends lua value to other script or scripts (_avaialble from: 4.5.0_). +* `aio:actions()` - returns a list of available actions. Format of table elements returned by `aio:available_widgets()`: @@ -288,6 +311,14 @@ Format of table elements returned by `aio:active_widgets()`: * `position` - position on the screen; * `folded` - true if widget is folded. +Format of table elements returned by `aio:actions()`: + +``` +* `name` - action name; +* `short_name` - action short name; +* `label` - action name visible to the user. +``` + To accept a value sent by the `send_message` function, the receiving script must implement a callback `on_message(value)`. The script can track screen operations such as adding, removing or moving a widget with the `on_widget_action()` callback. For example: @@ -310,11 +341,24 @@ end ## Application management -* `apps:list([sort_by], [no_hidden])` - returns the package table of all installed applications, `sort_by` - sort option (see below), `no_hidden` - true if no hidden applications are needed; +* `apps:list([sort_by], [no_hidden])` - returns the package table of all installed applications (if it is cloned app or Android for Work app package name will also contain user id, like that: `com.example.app:123`), `sort_by` - sort option (see below), `no_hidden` - true if no hidden applications are needed; * `apps:name(package)` - returns application name; * `apps:color(package)` - returns the color of the application in #XXXXXXXX format; * `apps:launch(package)` - launches the application; -* `apps:show_edit_dialog(package)` - shows edit dialog of the application. +* `apps:show_edit_dialog(package)` - shows edit dialog of the application; +* `apps:categories()` - returns a table of category tables; +* `apps:by_category(category_id)` - returns a table of application packages belonging to the specified category; +* `apps:request_icons(packages)` - requests icons for the specified list of applications, the result will be returned in the `on_icons_ready()` callback. + +The format of the category table: + +``` +* `id` - category id (id above 1000 are custom categories); +* `name` - category name; +* `icon` - category icon; +* `color` - category color; +* `hidden` - the category is hidden by the user. +``` Sorting options: @@ -341,10 +385,12 @@ If there is a problem with the network, the `on_network_error_$id` callback will ## Calendar -* `calendar:events([start_date], [end_date], [cal_table])` - returns table of event tables of all calendars, start\_date - event start date, end\_date - event end date, cal\_table - calendar ID table; +* `calendar:events([start_date], [end_date], [cal_table])` - returns table of event tables of all calendars, start\_date - event start date, end\_date - event end date, cal\_table - calendar ID table (function will return the string `permission_error` if the launcher does not have permissions to read the calendar); +* `calendar:request_permission()` - requests access rights to the calendar; * `calendar:calendars()` - returns table of calendars tables; * `calendar:show_event_dialog(id)` - shows the event dialog; -* `calendar:open_ovent(id)` - opens an event in the system calendar; +* `calendar:open_event(id|event_table)` - opens an event in the system calendar; +* `calendar:open_new_event([start], [end])` - opens a new event in the calendar, `start` - start date of the event in seconds, `end` - end date of the event; * `calendar:add_event(event_table)` - adds event to the system calendar. Event table format: @@ -368,10 +414,12 @@ Calendar table format: ## Phone -* `phone:contacts()` - returns table of phone contacts; +* `phone:contacts()` - returns table of phone contacts (function will return the string `permission_error` if the launcher does not have permissions to read the calendar); +* `phone:request_permission()` - requests access rights to the contacts; * `phone:make_call(number)` - dial the number in the dialer; * `phone:send_sms(number, [text])` - open SMS application and enter the number, optionally enter text; -* `phone:show_contact_dialog(id)` - open contact dialog; +* `phone:show_contact_dialog(id|lookup_key)` - open contact dialog; +* `phone:request_icons(cantact_ids)` - requests icons of contacts with specified IDs, the result will be in the `on_icons_ready` callback. Contacts table format: @@ -380,6 +428,49 @@ Contacts table format: * `name` - contact name; * `number` - contact number. +## Tasks + +_Avaialble from: 4.8.0_ + +* `tasks:load()` - loads tasks; +* `tasks:add(task_table)` - adds the task described in the table; +* `tasks:remove(task_id)` - removes the task with the specified ID; +* `tasks:save(task_table)` - saves the task; +* `tasks:show_editor(task_id)` - shows the task editing dialog. + +Once the tasks are loaded, the `on_tasks_loaded()` function will be executed. + +The format of the task table: + +* `id` - task ID; +* `text` - text; +* `date` - date of creation; +* `due_date` - deadline; +* `completed_date` - task completion date; +* `high_priority` - flag of high priority; +* `notification` - flag of notification display; +* `is_today` - is it today's task? + +## Notes + +_Avaialble from: 4.8.0_ + +* `notes:load()` - loads notes; +* `notes:add(note_table)` - adds the note described in the table; +* `notes:remove(note_id)` - removes the note with the specified ID; +* `notes:save(note_table)` - saves the note; +* `notes:colors()` - returns a list of colors (index is the color ID); +* `notes:show_editor(note_id)` - shows the note editing dialog. + +Once the notes are loaded, the `on_notes_loaded()` function will be executed. + +The format of the note table: + +* `id` - note ID; +* `text` - text; +* `color` - note color ID; +* `position` - note position on the screen. + ## Weather _Avaialble from: 4.1.0_ -- 2.43.0 From cdb9b7aec6d7058154a3492a090ad1680b79ce14 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 15 Jul 2023 16:57:11 +0400 Subject: [PATCH 036/204] Fix README --- README.md | 168 +++++++++++++++++++++++++++++------------------------- 1 file changed, 89 insertions(+), 79 deletions(-) diff --git a/README.md b/README.md index 14ad92c..37fb0d0 100644 --- a/README.md +++ b/README.md @@ -74,27 +74,19 @@ With side menu scripts, you can display your own list in the menu. The script ca The script starts with the following function: -``` -on_drawer_open() - -``` +`on_drawer_open()` In this function, you must prepare a list and display it using one of the following functions: -``` -* ``drawer:show_list(lines, [icons], [badges], [show_alphabet])`` - shows lines, optionally you can specify a table of icons (in `fa:icon_name` format), a table of lines to be displayed in badges and pass a boolean value: whether to show the alphabet; -* ``drawer:show_ext_lines(lines, [max_lines)`` - shows multiline lines, optionally you can specify the maximum number of lines of each element (default is 5). - -``` +* `drawer:show_list(lines, [icons], [badges], [show_alphabet])` - shows lines, optionally you can specify a table of icons (in `fa:icon_name` format), a table of lines to be displayed in badges and pass a boolean value: whether to show the alphabet; +* `drawer:show_ext_lines(lines, [max_lines)` - shows multiline lines, optionally you can specify the maximum number of lines of each element (default is 5). The following functions are also available: -``` -* ``drawer:add_buttons(icons, default_index)`` - shows icons at the bottom of the menu (in `fa:icon_name` format), `default_index` is the index of the selected icon; +* `drawer:add_buttons(icons, default_index)` - shows icons at the bottom of the menu (in `fa:icon_name` format), `default_index` is the index of the selected icon; * `drawer:clear()` - clears the list; * `drawer:close()` - closes the menu; * `drawer:change_view(name)` - switches the menu to another script or display style (argument: either script file name, `sortable` or `categories`). -``` Clicking on list items will call `on_click(index)`, long-clicking will call `on_long_click(index)`, clicking a bottom icon will call `on_button_click(index)`. @@ -297,26 +289,30 @@ Intent table format (all fields are optional): Format of table elements returned by `aio:available_widgets()`: -* `name` - internal name of the widget; -* `label` - title of the widget; -* `type` - widget type: `builtin`, `script` or `plugin`; -* `description` - widget description (usually empty for non-script widgets); -* `clonable` - true if the widget can have clones (examples: "My apps", "Contacts", "Mailbox" widgets); -* `enabled` - true if the widget is placed on the screen. +``` +`name` - internal name of the widget; +`label` - title of the widget; +`type` - widget type: `builtin`, `script` or `plugin`; +`description` - widget description (usually empty for non-script widgets); +`clonable` - true if the widget can have clones (examples: "My apps", "Contacts", "Mailbox" widgets); +`enabled` - true if the widget is placed on the screen. +``` Format of table elements returned by `aio:active_widgets()`: -* `name` - internal name of the widget; -* `label` - widget visible name; -* `position` - position on the screen; -* `folded` - true if widget is folded. +``` +`name` - internal name of the widget; +`label` - widget visible name; +`position` - position on the screen; +`folded` - true if widget is folded. +``` Format of table elements returned by `aio:actions()`: ``` -* `name` - action name; -* `short_name` - action short name; -* `label` - action name visible to the user. +`name` - action name; +`short_name` - action short name; +`label` - action name visible to the user. ``` To accept a value sent by the `send_message` function, the receiving script must implement a callback `on_message(value)`. @@ -353,11 +349,11 @@ end The format of the category table: ``` -* `id` - category id (id above 1000 are custom categories); -* `name` - category name; -* `icon` - category icon; -* `color` - category color; -* `hidden` - the category is hidden by the user. +`id` - category id (id above 1000 are custom categories); +`name` - category name; +`icon` - category icon; +`color` - category color; +`hidden` - the category is hidden by the user. ``` Sorting options: @@ -395,22 +391,26 @@ If there is a problem with the network, the `on_network_error_$id` callback will Event table format: -* `id` - event ID; -* `calendar_id` - calendar ID; -* `title` - title of the event; -* `description` - description of the event; -* `color` - color of the event; -* `status` - status string of the event or empty; -* `location` - address of the event by string; -* `begin` - start time of the event (in seconds); -* `end` - time of the event end (in seconds); -* `all_day` - boolean value, which means that the event lasts all day. +``` +`id` - event ID; +`calendar_id` - calendar ID; +`title` - title of the event; +`description` - description of the event; +`color` - color of the event; +`status` - status string of the event or empty; +`location` - address of the event by string; +`begin` - start time of the event (in seconds); +`end` - time of the event end (in seconds); +`all_day` - boolean value, which means that the event lasts all day. +``` Calendar table format: -* `id` - calendar identifier; -* `name` - name of the calendar; -* `color` - color of the calendar in the format #XXXXXXXX. +``` +`id` - calendar identifier; +`name` - name of the calendar; +`color` - color of the calendar in the format #XXXXXXXX. +``` ## Phone @@ -423,10 +423,12 @@ Calendar table format: Contacts table format: -* `id` - contact id; -* `lookup_key` - unique contact identifier; -* `name` - contact name; -* `number` - contact number. +``` +`id` - contact id; +`lookup_key` - unique contact identifier; +`name` - contact name; +`number` - contact number. +``` ## Tasks @@ -442,14 +444,16 @@ Once the tasks are loaded, the `on_tasks_loaded()` function will be executed. The format of the task table: -* `id` - task ID; -* `text` - text; -* `date` - date of creation; -* `due_date` - deadline; -* `completed_date` - task completion date; -* `high_priority` - flag of high priority; -* `notification` - flag of notification display; -* `is_today` - is it today's task? +``` +`id` - task ID; +`text` - text; +`date` - date of creation; +`due_date` - deadline; +`completed_date` - task completion date; +`high_priority` - flag of high priority; +`notification` - flag of notification display; +`is_today` - is it today's task? +``` ## Notes @@ -466,10 +470,12 @@ Once the notes are loaded, the `on_notes_loaded()` function will be executed. The format of the note table: -* `id` - note ID; -* `text` - text; -* `color` - note color ID; -* `position` - note position on the screen. +``` +`id` - note ID; +`text` - text; +`color` - note color ID; +`position` - note position on the screen. +``` ## Weather @@ -479,12 +485,14 @@ _Avaialble from: 4.1.0_ Function returns the weather data in the `on_weather_result(result)` callback, where `result` is a table of tables with the following fields: -* `time` - time in seconds; -* `temp` - temperature; -* `icon_code` - code of weather icon; -* `humidity` - humidity; -* `wind_speed` - wind speed; -* `wind_direction` - wind direction. +``` +`time` - time in seconds; +`temp` - temperature; +`icon_code` - code of weather icon; +`humidity` - humidity; +`wind_speed` - wind speed; +`wind_direction` - wind direction. +``` ## Cloud @@ -514,20 +522,22 @@ The `notify:request_current()` function asks for all current notifications. The Notification table format: -* `key` - a key uniquely identifying the notification; -* `time` - time of notification publication in seconds; -* `package` - name of the application package that sent the notification; -* `number` - the number on the notification badge, if any; -* `importance` - notification importance level: from 1 (low) to 4 (high), 3 - standard; -* `category` - notification category, for example `email`; -* `title` - notification title; -* `text` - notification text; -* `sub_text` - additional notification text; -* `big_text` - extended notification text; -* `is_clearable` - true, if the notification is clearable; -* `group_id` - notification group ID; -* `messages` - table of tables with fields: `sender`, `text`, `time` (_available from: 4.1.5_); -* `actions` - table notifications actions with fields: `id`, `title`, `have_input` (_available from: 4.1.5_); +``` +`key` - a key uniquely identifying the notification; +`time` - time of notification publication in seconds; +`package` - name of the application package that sent the notification; +`number` - the number on the notification badge, if any; +`importance` - notification importance level: from 1 (low) to 4 (high), 3 - standard; +`category` - notification category, for example `email`; +`title` - notification title; +`text` - notification text; +`sub_text` - additional notification text; +`big_text` - extended notification text; +`is_clearable` - true, if the notification is clearable; +`group_id` - notification group ID; +`messages` - table of tables with fields: `sender`, `text`, `time` (_available from: 4.1.5_); +`actions` - table notifications actions with fields: `id`, `title`, `have_input` (_available from: 4.1.5_); +``` Keep in mind that the AIO Launcher also calls `request_current()` every time you return to the launcher, which means that all scripts will also get notification information in the `on_notify_posted()` callback every time you return to the desktop. -- 2.43.0 From 3806581020eb1882adcdbe4a8d0a70efc2c3ba38 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 15 Jul 2023 17:41:29 +0400 Subject: [PATCH 037/204] Fix Widgets switcher widget --- main/widgets-on-off.lua | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/main/widgets-on-off.lua b/main/widgets-on-off.lua index 8f31960..f554cba 100644 --- a/main/widgets-on-off.lua +++ b/main/widgets-on-off.lua @@ -7,11 +7,11 @@ --constants-- -local widgets = {"weather","weatheronly","clock","alarm","worldclock","monitor","traffic","player","apps","appbox","applist","contacts","notify","dialogs","dialer","timer","stopwatch","mail","notes","tasks", "health", "feed","telegram","calendar","exchange","finance","bitcoin","control","recorder","calculator","empty","bluetooth","map","remote"} +local widgets = {"weather","weatheronly","clock","alarm","worldclock","monitor","traffic","player","apps","appbox","applist","appfolders","contacts","notify","dialogs","dialer","timer","stopwatch","mail","notes","tasks", "health", "feed","telegram","calendar","calendarw","exchange","finance","bitcoin","control","recorder","calculator","empty"} -local icons = {"fa:user-clock","fa:sun-cloud","fa:clock","fa:alarm-clock","fa:business-time","fa:network-wired","fa:exchange","fa:play-circle","fa:robot","fa:th","fa:list","fa:address-card","fa:bell","fa:comment-alt-minus","fa:phone-alt","fa:chess-clock","fa:stopwatch","fa:at","fa:sticky-note","fa:calendar-check", "fa:heart-pulse", "fa:rss-square","fa:paper-plane","fa:calendar-alt","fa:euro-sign","fa:chart-line","fa:coins","fa:wifi","fa:microphone-alt","fa:calculator-alt","fa:eraser","fa:head-side-headphones","fa:map-marked-alt","fa:user-tag"} +local icons = {"fa:user-clock","fa:sun-cloud","fa:clock","fa:alarm-clock","fa:business-time","fa:network-wired","fa:exchange","fa:play-circle","fa:robot","fa:th","fa:list","fa:folder","fa:address-card","fa:bell","fa:comment-alt-minus","fa:phone-alt","fa:chess-clock","fa:stopwatch","fa:at","fa:sticky-note","fa:calendar-check", "fa:heart-pulse", "fa:rss-square","fa:paper-plane","fa:calendar-alt","fa:calendar-week","fa:euro-sign","fa:chart-line","fa:coins","fa:wifi","fa:microphone-alt","fa:calculator-alt","fa:eraser"} -local names = {"Clock & weather","Weather","Clock","Alarm","Worldclock","Monitor","Traffic","Player","Frequent apps","My apps","App list","Contacts","Notify","Dialogs","Dialer","Timer","Stopwatch","Mail","Notes","Tasks", "Health", "Feed","Telegram","Calendar","Exchange","Finance","Bitcoin","Control panel","Recorder","Calculator","Empty widget","Bluetooth","Map","User widget"} +local names = {"Clock & weather","Weather","Clock","Alarm","World clock","Monitor","Traffic","Player","Frequent apps","My apps","App list","App folders","Contacts","Notify","Dialogs","Dialer","Timer","Stopwatch","Mail","Notes","Tasks", "Health", "Feed","Telegram","Calendar","Weekly calendar","Exchange","Finance","Bitcoin","Control panel","Recorder","Calculator","Empty widget"} --variables-- @@ -98,10 +98,13 @@ function get_buttons() local checkbox_idx = get_checkbox_idx() for i = 1, #checkbox_idx do table.insert(buttons, icons[checkbox_idx[i]]) - if aio:is_widget_added(widgets[checkbox_idx[i]]) then - table.insert(colors, "#1976d2") - else - table.insert(colors, "#909090") + local widget = widgets[checkbox_idx[i]] + if widget ~= nil then + if aio:is_widget_added(widget) then + table.insert(colors, "#1976d2") + else + table.insert(colors, "#909090") + end end end return buttons,colors -- 2.43.0 From 66ee4ef452d968ebbb5c9847a0ac2818d84724ea Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 15 Jul 2023 17:43:02 +0400 Subject: [PATCH 038/204] Update zip --- scripts.index | 3 +++ scripts.md5 | 2 +- scripts.zip | Bin 19821 -> 22181 bytes 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts.index b/scripts.index index 8eec024..132246c 100644 --- a/scripts.index +++ b/scripts.index @@ -1,5 +1,7 @@ battery-widget.lua calendar.lua +calendar-menu.lua +contacts-menu.lua covid-widget.lua dice-widget.lua facts-widget.lua @@ -9,6 +11,7 @@ public-ip-widget.lua quotes-widget.lua shell-widget.lua sys-info-widget.lua +tasks-menu.lua unit-converter.lua uptimerobot-widget.lua widgets-on-off.lua diff --git a/scripts.md5 b/scripts.md5 index c54d2ee..c13402a 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -8edd7e6979e2f1009a2dd9bdc7b7ee39 +3138409087cb382db8f8d0190e46519c diff --git a/scripts.zip b/scripts.zip index 97ce358a621a277c9d7fa96f5c9e9c2a316475f4..1a5cb068b4c64a30a31aeca01b7e1772aa8337e6 100644 GIT binary patch delta 6570 zcmZX2WmH^A*L7n_aCZr=A$a2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-9wwowHTU9^; bQ%k6yDrjdaNkI#tg Date: Sat, 15 Jul 2023 18:20:51 +0400 Subject: [PATCH 039/204] Add side menu scripts to the README header --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 37fb0d0..d907a6a 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,17 @@ Starting from version 4.0, AIO Launcher supports scripts written in the [Lua scripting language](https://en.wikipedia.org/wiki/Lua_(programming_language)). Scripts should be placed in the directory `/sdcard/Android/data/ru.execbit.aiolauncher/files/`. -There are two types of scripts: +There are three types of scripts: * _Widget scripts_, which can be added to the desktop using the side menu. * _Search scripts_ that add results to the search box. These can be enabled in the settings. +* _Side menu scripts_ that change the side menu. The type of script is determined by the line (meta tag) at the beginning of the file: * `-- type = "widget"` * `-- type = "search"` +* `-- type = "drawer"` *Read more about meta tags at the end of the document.* -- 2.43.0 From 43328239c963f50e975151e1afe843c21760ee4f Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 16 Jul 2023 09:54:01 +0400 Subject: [PATCH 040/204] Some README fixes --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d907a6a..16071e8 100644 --- a/README.md +++ b/README.md @@ -76,12 +76,12 @@ With side menu scripts, you can display your own list in the menu. The script ca The script starts with the following function: -`on_drawer_open()` +* `on_drawer_open()` In this function, you must prepare a list and display it using one of the following functions: * `drawer:show_list(lines, [icons], [badges], [show_alphabet])` - shows lines, optionally you can specify a table of icons (in `fa:icon_name` format), a table of lines to be displayed in badges and pass a boolean value: whether to show the alphabet; -* `drawer:show_ext_lines(lines, [max_lines)` - shows multiline lines, optionally you can specify the maximum number of lines of each element (default is 5). +* `drawer:show_ext_list(lines, [max_lines)` - shows multiline lines, optionally you can specify the maximum number of lines of each element (default is 5). The following functions are also available: @@ -259,7 +259,7 @@ The function takes a command table of this format as a parameter: The result of executing a shell command is sent to the `on_shell_result(string)` callback. -## Intens +## Intents * `intent:start_activity(table)` - starts activity with intent described in the table; * `intent:send_broadcast(table)` - sends broadcast intent described in the table. @@ -285,7 +285,7 @@ Intent table format (all fields are optional): * `aio:is_widget_added(string)` - checks if the widget is added to the screen; * `aio:self_name()` - returns current script file name (_available from: 4.5.0_); * `aio:send_message(value, [script_name])` - sends lua value to other script or scripts (_avaialble from: 4.5.0_); -* `ui:colors()` - returns table with current theme colors; +* `aio:colors()` - returns table with current theme colors; * `aio:do_action(string)` - performs an AIO action ([more](https://aiolauncher.app/api.html)); * `aio:actions()` - returns a list of available actions. @@ -414,6 +414,8 @@ Calendar table format: `color` - color of the calendar in the format #XXXXXXXX. ``` +The function `calendar:request_permission()` calls `on_permission_granted()` callback if the user agrees to grant permission. + ## Phone * `phone:contacts()` - returns table of phone contacts (function will return the string `permission_error` if the launcher does not have permissions to read the calendar); @@ -432,6 +434,8 @@ Contacts table format: `number` - contact number. ``` +The function `phone:request_permission()` calls `on_permission_granted()` callback if the user agrees to grant permission. + ## Tasks _Avaialble from: 4.8.0_ -- 2.43.0 From d098a0f84d4277265da383818d8376550f77097e Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 19 Jul 2023 14:00:35 +0400 Subject: [PATCH 041/204] Optimize default drawer scripts --- main/calendar-menu.lua | 4 ++++ main/contacts-menu.lua | 4 ++++ samples/apps-menu.lua | 26 ++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 samples/apps-menu.lua diff --git a/main/calendar-menu.lua b/main/calendar-menu.lua index af4f3b8..0fba9a1 100644 --- a/main/calendar-menu.lua +++ b/main/calendar-menu.lua @@ -21,6 +21,10 @@ function on_drawer_open() have_permission = true + if #events == #drawer:items() then + return + end + lines = map(events, function(it) local date = fmt.colored(os.date("%d.%m", it.begin), it.color) return date..fmt.space(4)..it.title diff --git a/main/contacts-menu.lua b/main/contacts-menu.lua index 36013e6..93d72b1 100644 --- a/main/contacts-menu.lua +++ b/main/contacts-menu.lua @@ -22,6 +22,10 @@ function on_drawer_open() sort_by_name(phone:contacts()) ) + if #contacts == #drawer:items() then + return + end + names = map(contacts, function(it) return it.name end) keys = map(contacts, function(it) return it.lookup_key end) diff --git a/samples/apps-menu.lua b/samples/apps-menu.lua new file mode 100644 index 0000000..536bdf0 --- /dev/null +++ b/samples/apps-menu.lua @@ -0,0 +1,26 @@ +-- name = "Apps menu" +-- type = "drawer" +-- testing = "true" + +function on_drawer_open() + apps_tab = apps:list() + debug:toast("called") + + -- Do not update if the list of the apps is not changed + if #apps_tab ~= #drawer:items() then + update() + end +end + +function update() + names_tab = map(function(it) return apps:name(it) end, apps_tab) + apps:request_icons(apps_tab) +end + +function on_icons_ready(icons_tab) + drawer:show_list(names_tab, icons_tab, nil, true) +end + +function on_click(idx) + apps:launch(apps_tab[idx]) +end -- 2.43.0 From 878c96ec88c9c079a1ec10460d0a7a1f08220f0f Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 19 Jul 2023 19:15:05 +0400 Subject: [PATCH 042/204] Add long click action to the tasks-menu.lua --- community/settings-menu.lua | 17 +++++++++++++++++ main/tasks-menu.lua | 16 ++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 community/settings-menu.lua diff --git a/community/settings-menu.lua b/community/settings-menu.lua new file mode 100644 index 0000000..203d63a --- /dev/null +++ b/community/settings-menu.lua @@ -0,0 +1,17 @@ +-- name = "Settings menu" +-- name_id = "settings" +-- description = "Side menu with AIO settings" +-- aio_version = "4.7.99" +-- type = "drawer" +-- author = "Evgeny Zobnin (zobnin@gmail.com) +-- version = "1.0" + +function on_drawer_open() + settings = aio:settings() + labels = map(function(it) return it.label end, settings) + drawer:show_list(labels) +end + +function on_click(idx) + aio:open_settings(settings[idx].name) +end diff --git a/main/tasks-menu.lua b/main/tasks-menu.lua index 934a49c..65d6383 100644 --- a/main/tasks-menu.lua +++ b/main/tasks-menu.lua @@ -94,6 +94,22 @@ function on_task_click(idx) tasks:show_editor(tasks_list[idx].id) end +function on_long_click(idx) + if prefs.curr_tab == 1 then + on_note_long_click(idx) + else + on_task_long_click(idx) + end +end + +function on_note_long_click(idx) + system:to_clipboard(notes_list[idx].text) +end + +function on_task_long_click(idx) + system:to_clipboard(tasks_list[idx].text) +end + function on_button_click(idx) if idx < 3 then prefs.curr_tab = idx -- 2.43.0 From aa131b2e094dc0807a530d02958874823cc1bfbf Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 21 Jul 2023 15:43:41 +0400 Subject: [PATCH 043/204] Small fixes --- community/icndb-translate-widget.lua | 2 +- samples/shttp-text.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/community/icndb-translate-widget.lua b/community/icndb-translate-widget.lua index 5384e18..3a1639a 100644 --- a/community/icndb-translate-widget.lua +++ b/community/icndb-translate-widget.lua @@ -1,4 +1,4 @@ --- name = "Chuck Norris translated" +-- name = "Chuck Norris jokes" -- description = "Jokes with translation" -- data_source = "icndb.com" -- type = "widget" diff --git a/samples/shttp-text.lua b/samples/shttp-text.lua index de3bbe3..da91fbc 100644 --- a/samples/shttp-text.lua +++ b/samples/shttp-text.lua @@ -1,4 +1,4 @@ --- name = "Chuck Norris jokes (experimental)" +-- name = "Chuck Norris jokes (sync)" -- description = "icndb.com" -- data_source = "icndb.com" -- type = "widget" -- 2.43.0 From 82526addad2cd2c94f12b0c27747b47a9da4c182 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 21 Jul 2023 15:44:03 +0400 Subject: [PATCH 044/204] Update zip --- scripts.md5 | 2 +- scripts.zip | Bin 22181 -> 22256 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts.md5 b/scripts.md5 index c13402a..afb01d9 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -3138409087cb382db8f8d0190e46519c +116b50de4ba91eb0863412881f2be745 diff --git a/scripts.zip b/scripts.zip index 1a5cb068b4c64a30a31aeca01b7e1772aa8337e6..cd255982b9ce0b62ce52e0ea8527da7e32f259f2 100644 GIT binary patch delta 2531 zc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mVrRBaWc+VPZOq%&yPn{2BYE0()eXLG7q) zNsK_nG>*69{HAwtGc&zt3%cQx8{*zgzG5&@`m)AdDNvvrMJ@cklciw2J&}csP zmt1q7hHMS*wX|wQIkDIa?W?|M3#_^N)N$hpB0^lPNz-k0V7Yjs`)G(;8ceDAS!R0d zV{devYWBp{S5Y@`VLLl8Vp<2tm~dQ43vbhlGVXP9_4Bk8Y6{$kW}^Fqq}^R#k}w1o zBR!4p?}ZwJYwX||6RU8r6j_k*E z@5pUouRKbbogLLFCsb9$j%j=$8*NH`x9^p#L|AIXh><=STO!aJ4;K|MY=c82=Wi>(#)(Y`l2+yg@nd zb_mhE{oO-Nts$_yp90Wm79zL>7MMfOEr_&ZZHEl8MCkAJM%D=}p3PbVoOgtq{o9pf ze!3L^{47m?yeLm0;C~+VivsWhuuY@d+yJz+SA^7q9`*!?ELdrehZKVRI08fgJcaXu zHA(^ChLkKgg0qASfl3Z8Jm25|0FrT1;4KGpNFdnlK!8ms0-&;z6lme7qV#Y1`SmuB zK$@cz&!+ZlolI5RCG=}p8SHa(hTH+Q@ve}QARX@vQ3T)NU7*t@pb5bZcF+s}@0)F2 nMg@FBP=uA+03aMA3ko|~LciF8_D&}u#bB}1p&d7mZ$7|3wI_14 -- 2.43.0 From 029cc39c7fae03157d681919d3440f0991df0d9d Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 21 Jul 2023 18:11:34 +0400 Subject: [PATCH 045/204] README: add new APIs --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 16071e8..f170f9e 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,10 @@ The type of script is determined by the line (meta tag) at the beginning of the * The `apps` modules now returns also Android for Work and cloned apps; * The `apps` module now allows you to sort apps by category; * The `phone` and `calendar` modules now have functions for requesting access rights; +* Added `phone:open_contact() function; * Added `aio:actions()` function that returns a table of AIO Launcher actions; * Added `calendar:open_new_event()` function that shows the system calendar with the new event. +* Added `aio:settings()` and `aio:open_settings()` functions # Widget scripts @@ -287,7 +289,9 @@ Intent table format (all fields are optional): * `aio:send_message(value, [script_name])` - sends lua value to other script or scripts (_avaialble from: 4.5.0_); * `aio:colors()` - returns table with current theme colors; * `aio:do_action(string)` - performs an AIO action ([more](https://aiolauncher.app/api.html)); -* `aio:actions()` - returns a list of available actions. +* `aio:actions()` - returns a list of available actions; +* `aio:settings()` - returns a list of available AIO Settings sections; +* `aio:open_settings([section])` - open AIO Settings or AIO Settings section. Format of table elements returned by `aio:available_widgets()`: @@ -423,6 +427,7 @@ The function `calendar:request_permission()` calls `on_permission_granted()` cal * `phone:make_call(number)` - dial the number in the dialer; * `phone:send_sms(number, [text])` - open SMS application and enter the number, optionally enter text; * `phone:show_contact_dialog(id|lookup_key)` - open contact dialog; +* `phone:open_contact(id)` - open contact in the contacts app; * `phone:request_icons(cantact_ids)` - requests icons of contacts with specified IDs, the result will be in the `on_icons_ready` callback. Contacts table format: -- 2.43.0 From 7151dc73a0843404374f9529698e32eb120877fb Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 26 Jul 2023 11:26:18 +0400 Subject: [PATCH 046/204] 1. Small fixes to main widget. 2. Covid widget removed as defunct. --- defunct/covid-widget.lua | 33 ++++++++++++++++++++++++++++++ main/covid-widget.lua | 30 --------------------------- main/facts-widget.lua | 9 ++++---- main/inspiration-quotes-widget.lua | 1 - main/public-ip-widget.lua | 6 ++++-- main/quotes-widget.lua | 10 +++++---- main/tasks-menu.lua | 8 ++++---- main/wikipedia-widget.lua | 22 +++++++++++--------- 8 files changed, 64 insertions(+), 55 deletions(-) create mode 100644 defunct/covid-widget.lua delete mode 100644 main/covid-widget.lua diff --git a/defunct/covid-widget.lua b/defunct/covid-widget.lua new file mode 100644 index 0000000..41e079a --- /dev/null +++ b/defunct/covid-widget.lua @@ -0,0 +1,33 @@ +-- name = "Covid info" +-- description = "Cases of illness and death from covid" +-- data_source = "covid19api.com" +-- type = "widget" +-- author = "Evgeny Zobnin (zobnin@gmail.com)" +-- version = "1.0" + +equals = " = " + +function on_alarm() + http:get("https://api.covid19api.com/summary") +end + +function on_network_result(result, code) + if code >= 200 and code < 299 then + local new = ajson:get_value(result, "object object:Global int:NewConfirmed") + local total = ajson:get_value(result, "object object:Global int:TotalConfirmed") + local newDeaths = ajson:get_value(result, "object object:Global int:NewDeaths") + local totalDeaths = ajson:get_value(result, "object object:Global int:TotalDeaths") + + ui:show_lines({ + "Disease | total"..equals..comma_value(total).." | new"..equals..comma_value(new), + "Deaths | total"..equals..comma_value(totalDeaths).." | new"..equals..comma_value(newDeaths) + }) + end +end + +-- credit http://richard.warburton.it +function comma_value(n) + local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$') + return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right +end + diff --git a/main/covid-widget.lua b/main/covid-widget.lua deleted file mode 100644 index 626e57f..0000000 --- a/main/covid-widget.lua +++ /dev/null @@ -1,30 +0,0 @@ --- name = "Covid info" --- description = "Cases of illness and death from covid" --- data_source = "covid19api.com" --- type = "widget" --- author = "Evgeny Zobnin (zobnin@gmail.com)" --- version = "1.0" - -equals = " = " - -function on_alarm() - http:get("https://api.covid19api.com/summary") -end - -function on_network_result(result) - local new = ajson:get_value(result, "object object:Global int:NewConfirmed") - local total = ajson:get_value(result, "object object:Global int:TotalConfirmed") - local newDeaths = ajson:get_value(result, "object object:Global int:NewDeaths") - local totalDeaths = ajson:get_value(result, "object object:Global int:TotalDeaths") - - ui:show_lines({ - "Disease | total"..equals..comma_value(total).." | new"..equals..comma_value(new), - "Deaths | total"..equals..comma_value(totalDeaths).." | new"..equals..comma_value(newDeaths) - }) -end - -function comma_value(n) -- credit http://richard.warburton.it - local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$') - return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right -end - diff --git a/main/facts-widget.lua b/main/facts-widget.lua index bd30aa8..10da273 100644 --- a/main/facts-widget.lua +++ b/main/facts-widget.lua @@ -10,10 +10,11 @@ function on_alarm() http:get("https://uselessfacts.jsph.pl/random.json?language=en") end -function on_network_result(result) - text = ajson:get_value(result, "object string:text") - - ui:show_lines{ text } +function on_network_result(result, code) + if code >= 200 and code < 299 then + text = ajson:get_value(result, "object string:text") + ui:show_lines{ text } + end end function on_click() diff --git a/main/inspiration-quotes-widget.lua b/main/inspiration-quotes-widget.lua index 0297b24..4c997b6 100644 --- a/main/inspiration-quotes-widget.lua +++ b/main/inspiration-quotes-widget.lua @@ -15,7 +15,6 @@ end function on_network_result(result, code) if code >= 200 and code < 299 then res = json.decode(result) - ui:show_lines({ res[1].q }, { res[1].a }) end end diff --git a/main/public-ip-widget.lua b/main/public-ip-widget.lua index 96096ef..a08daea 100644 --- a/main/public-ip-widget.lua +++ b/main/public-ip-widget.lua @@ -10,6 +10,8 @@ function on_alarm() http:get("https://api.ipify.org") end -function on_network_result(result) - ui:show_text(result) +function on_network_result(result, code) + if code >= 200 and code < 299 then + ui:show_text(result) + end end diff --git a/main/quotes-widget.lua b/main/quotes-widget.lua index 6a2bd81..c62f6f7 100644 --- a/main/quotes-widget.lua +++ b/main/quotes-widget.lua @@ -10,11 +10,13 @@ function on_alarm() http:get("https://api.quotable.io/random") end -function on_network_result(result) - quote = ajson:get_value(result, "object string:content") - author = ajson:get_value(result, "object string:author") +function on_network_result(result, code) + if code >= 200 and code < 299 then + quote = ajson:get_value(result, "object string:content") + author = ajson:get_value(result, "object string:author") - ui:show_lines({ quote }, { author }) + ui:show_lines({ quote }, { author }) + end end function on_click() diff --git a/main/tasks-menu.lua b/main/tasks-menu.lua index 65d6383..dbdbc39 100644 --- a/main/tasks-menu.lua +++ b/main/tasks-menu.lua @@ -13,11 +13,11 @@ local primary_color = aio:colors().primary_color local secondary_color = aio:colors().secondary_color local bottom_buttons = { - "fa:note_sticky", -- notes tab - "fa:list-check", -- tasks tab - "fa:pipe", -- separator + "fa:note_sticky", -- notes tab + "fa:list-check", -- tasks tab + "fa:pipe", -- separator "fa:note_medical", -- new note button - "fa:square_plus" -- new task button + "fa:square_plus" -- new task button } local notes_list = {} diff --git a/main/wikipedia-widget.lua b/main/wikipedia-widget.lua index 5000cc9..a9c46ff 100644 --- a/main/wikipedia-widget.lua +++ b/main/wikipedia-widget.lua @@ -18,18 +18,20 @@ function on_alarm() http:get(random_url) end -function on_network_result(result) - local parsed = json.decode(result) - title = parsed.query.random[1].title - - http:get(summary_url.."&titles="..url.quote(title), "summary") +function on_network_result(result, code) + if code >= 200 and code < 299 then + local parsed = json.decode(result) + title = parsed.query.random[1].title + http:get(summary_url.."&titles="..url.quote(title), "summary") + end end -function on_network_result_summary(result) - local parsed = json.decode(result) - local extract = get_extract(parsed) - - ui:show_lines({ smart_sub(extract, 200) }, { title }) +function on_network_result_summary(result, code) + if code >= 200 and code < 299 then + local parsed = json.decode(result) + local extract = get_extract(parsed) + ui:show_lines({ smart_sub(extract, 200) }, { title }) + end end function on_click() -- 2.43.0 From 6a48001a9e4c8e772471538448cedc2d3cc13e69 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 26 Jul 2023 11:26:32 +0400 Subject: [PATCH 047/204] Update zip --- scripts.index | 1 - scripts.md5 | 2 +- scripts.zip | Bin 22256 -> 21694 bytes 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts.index b/scripts.index index 132246c..a20985b 100644 --- a/scripts.index +++ b/scripts.index @@ -2,7 +2,6 @@ battery-widget.lua calendar.lua calendar-menu.lua contacts-menu.lua -covid-widget.lua dice-widget.lua facts-widget.lua inspiration-quotes-widget.lua diff --git a/scripts.md5 b/scripts.md5 index afb01d9..6553deb 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -116b50de4ba91eb0863412881f2be745 +71323911ba57c8db51356c2a3812998f diff --git a/scripts.zip b/scripts.zip index cd255982b9ce0b62ce52e0ea8527da7e32f259f2..75e6e9d61200e5943a2ae39785e42ea86e52af6e 100644 GIT binary patch delta 4193 zcmZu!c{r5o8~&Kd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Pk3Y{@~{f9z>svm#Z7}Y{xWE~AMW8`6EAq_q< zL+-0+PYeo5QqkZi49~t+et?mOk_7b6cV?5H@92NaW-bz20{{}Y1`5NbnSlQg(Ud<# zGW^Z0M6mDf$o3GLeeS7EO7r6WCBw;nXM>J zTFQ^)fcXyxNxWd5DJP6fZpgFM$i!wR!ha-`G<%XXoAr;`P<{Zw1>>Z={XDRLhn>uX z$S#!rU_rD1!1#xY9svLdbjF>*4X!2MPMgn-KUn>i?d2ZzZtY90?=iKiM&Czr$9{5fn;jklKPDMs74v z-I5 Date: Thu, 17 Aug 2023 18:58:02 +0400 Subject: [PATCH 048/204] Move Chuck Norris jokes to defunct --- {community => defunct}/icndb-translate-widget.lua | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {community => defunct}/icndb-translate-widget.lua (100%) diff --git a/community/icndb-translate-widget.lua b/defunct/icndb-translate-widget.lua similarity index 100% rename from community/icndb-translate-widget.lua rename to defunct/icndb-translate-widget.lua -- 2.43.0 From c8f0e8be795e644635e5a71ed632a414400a326b Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 17 Aug 2023 19:51:24 +0400 Subject: [PATCH 049/204] remove chart-sample2.lua --- samples/chart-sample2.lua | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 samples/chart-sample2.lua diff --git a/samples/chart-sample2.lua b/samples/chart-sample2.lua deleted file mode 100644 index 3a3da1f..0000000 --- a/samples/chart-sample2.lua +++ /dev/null @@ -1,39 +0,0 @@ -local api_url = "https://api.covid19api.com/country/ru?from=2021-07-01T00:00:00Z&to=2021-07-31T00:00:00Z" - -local tab = {} - -function on_alarm() - http:get(api_url) -end - -function on_network_result(result) - tab = get_tab_ajson(result) - ui:show_chart(tab, "x:date y:number") -end - -function totime(str) - local y,m,d = str:match("(%d+)-(%d+)-(%d+)") - return os.time{year=y, month=m, day=d}*1000 -end - -function get_tab_ajson(result) - local tab = {} - local dat = ajson:get_value(result, "array object:0 string:Date") - local conf = ajson:get_value(result, "array object:0 int:Confirmed") - local prev_conf = conf - local new = conf - prev_conf - tab[1] = {totime(dat), new} - local i = 1 - while true do - dat = ajson:get_value(result, "array object:"..i.." string:Date") - if dat:match("Error") == "Error" then - break - end - conf = ajson:get_value(result, "array object:"..i.." int:Confirmed") - new = conf - prev_conf - prev_conf = conf - tab[i] = {totime(dat), new} - i = i+1 - end - return tab -end -- 2.43.0 From 5ad5be396f9366cd79110bca295409933049cafb Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 8 Sep 2023 08:25:27 +0400 Subject: [PATCH 050/204] Add loclized date to the calendar-menu.lua script --- main/calendar-menu.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/main/calendar-menu.lua b/main/calendar-menu.lua index 0fba9a1..5af4289 100644 --- a/main/calendar-menu.lua +++ b/main/calendar-menu.lua @@ -26,13 +26,21 @@ function on_drawer_open() end lines = map(events, function(it) - local date = fmt.colored(os.date("%d.%m", it.begin), it.color) + local date = fmt.colored(format_date(it.begin), it.color) return date..fmt.space(4)..it.title end) drawer:show_ext_list(lines) end +function format_date(date) + if system.format_date_localized then + return system:format_date_localized("dd.MM", date) + else + return os.date("%d.%m", date) + end +end + function on_click(idx) if not have_permission then return end -- 2.43.0 From de23ba41def84853bb1fe2d7d9187e0f2487fd55 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 11 Sep 2023 11:36:09 +0400 Subject: [PATCH 051/204] Various fixes to support new AIO version --- main/battery-widget.lua | 7 +------ main/kodi-remote-widget.lua | 9 +++++++++ main/shell-widget.lua | 4 ++++ main/sys-info-widget.lua | 8 +------- main/uptimerobot-widget.lua | 9 +++++++++ 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/main/battery-widget.lua b/main/battery-widget.lua index f1b52f3..4d1e24d 100644 --- a/main/battery-widget.lua +++ b/main/battery-widget.lua @@ -2,17 +2,12 @@ -- description = "Simple battery info widget" -- author = "Evgeny Zobnin (zobnin@gmail.com)" -ticks = -1 - -function on_tick() +function on_tick(ticks) -- Update one time per 10 seconds - ticks = ticks + 1 if ticks % 10 ~= 0 then return end - ticks = 0 - local batt_info = system:battery_info() local batt_strings = stringify_table(batt_info) local folded_str = "Battery: "..batt_info.percent.."% | "..batt_info.temp.."° | "..batt_info.voltage.." mV" diff --git a/main/kodi-remote-widget.lua b/main/kodi-remote-widget.lua index 6c51a0c..970eb6e 100644 --- a/main/kodi-remote-widget.lua +++ b/main/kodi-remote-widget.lua @@ -28,6 +28,15 @@ local buttons_cmds = { prev_cmd, backward_cmd, play_cmd, stop_cmd, forward_cmd, local url = nil local curr_idx = nil +function on_preview() + if next(settings:get()) == nil then + ui:show_text("Remote control for Kodi multimedia player") + return + else + on_resume() + end +end + function on_resume() if next(settings:get()) == nil then ui:show_text("Tap to enter Kodi address") diff --git a/main/shell-widget.lua b/main/shell-widget.lua index a76578b..8049d41 100644 --- a/main/shell-widget.lua +++ b/main/shell-widget.lua @@ -7,6 +7,10 @@ current_output = "Click to enter command" +function on_preview() + ui:show_text("Shows the result of executing console commands") +end + function on_resume() redraw() end diff --git a/main/sys-info-widget.lua b/main/sys-info-widget.lua index 4054717..63d0cbc 100644 --- a/main/sys-info-widget.lua +++ b/main/sys-info-widget.lua @@ -4,17 +4,11 @@ -- author = "Evgeny Zobnin (zobnin@gmail.com)" -- version = "1.0" -ticks = -1 - -function on_tick() - -- Update one time per 10 seconds - ticks = ticks + 1 +function on_tick(ticks) if ticks % 10 ~= 0 then return end - ticks = 0 - local info = system:system_info() local strings = stringify_table(info) diff --git a/main/uptimerobot-widget.lua b/main/uptimerobot-widget.lua index cbfbc14..fb1a5a7 100644 --- a/main/uptimerobot-widget.lua +++ b/main/uptimerobot-widget.lua @@ -14,6 +14,15 @@ local api_url = "https://api.uptimerobot.com/v2/" local click_url = "https://uptimerobot.com/dashboard#mainDashboard" local media_type = "application/x-www-form-urlencoded" +function on_preview() + if (next(settings:get()) == nil) then + ui:show_text("Shows uptime information from uptimerobot.com") + return + else + on_alarm() + end +end + function on_alarm() if (next(settings:get()) == nil) then ui:show_text("Tap to enter API key") -- 2.43.0 From 7868273f7458e1a99cd967d0541b9b6a827c79d4 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 12 Sep 2023 15:52:28 +0400 Subject: [PATCH 052/204] Add script to remove all scripts from device --- env | 3 +++ install-scripts.sh | 5 ++--- rm-scripts.sh | 5 +++++ 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 env create mode 100755 rm-scripts.sh diff --git a/env b/env new file mode 100644 index 0000000..aee4990 --- /dev/null +++ b/env @@ -0,0 +1,3 @@ +REPOS="main ru samples community" +SCRIPTS_DIR="/sdcard/Android/data/ru.execbit.aiolauncher/files/" + diff --git a/install-scripts.sh b/install-scripts.sh index 29866f6..54837e1 100755 --- a/install-scripts.sh +++ b/install-scripts.sh @@ -1,9 +1,8 @@ #!/bin/sh -REPOS="main ru samples community" -SCRIPTS_DIR="/sdcard/Android/data/ru.execbit.aiolauncher/files/" +source ./env -adb shell rm -rf $SCRIPTS_DIR/*.lua +./rm-scripts.sh for repo in $REPOS; do adb push $repo/*.lua $SCRIPTS_DIR diff --git a/rm-scripts.sh b/rm-scripts.sh new file mode 100755 index 0000000..7fde099 --- /dev/null +++ b/rm-scripts.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +source ./env +adb shell rm -rf $SCRIPTS_DIR/*.lua + -- 2.43.0 From da6e0435d5bdc22840a0330325edc659a18ba752 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 20 Sep 2023 12:56:37 +0400 Subject: [PATCH 053/204] Contacts menu script: do not load real icons (slow) --- main/contacts-menu.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main/contacts-menu.lua b/main/contacts-menu.lua index 93d72b1..e8cf773 100644 --- a/main/contacts-menu.lua +++ b/main/contacts-menu.lua @@ -28,8 +28,12 @@ function on_drawer_open() names = map(contacts, function(it) return it.name end) keys = map(contacts, function(it) return it.lookup_key end) + icons = map(contacts, function(it) return it.name:sub(1,1) end) - phone:request_icons(keys) + drawer:show_list(names, icons, nil, true) + + -- Uncomment this if you want to use real icons (slow) + --phone:request_icons(keys) end function on_icons_ready(icons) -- 2.43.0 From bc003712ff5cb6082d244d3ded37de1b909a25d1 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 20 Sep 2023 13:27:33 +0400 Subject: [PATCH 054/204] Move sunrise/sunset script to the main folder --- community/sunrise-sunset-widget.lua | 25 ---------------------- main/sunrise-sunset-widget.lua | 32 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 25 deletions(-) delete mode 100644 community/sunrise-sunset-widget.lua create mode 100644 main/sunrise-sunset-widget.lua diff --git a/community/sunrise-sunset-widget.lua b/community/sunrise-sunset-widget.lua deleted file mode 100644 index 5f3129a..0000000 --- a/community/sunrise-sunset-widget.lua +++ /dev/null @@ -1,25 +0,0 @@ --- name = "Sunrise/Sunset" --- description = "Shows Sunrise Sunset at your location" --- data_source = "https://api.sunrise-sunset.org/" --- type = "widget" --- author = "Sriram S V" --- version = "1.0" --- foldable = "false" - -local json = require "json" -local date = require "date" -function on_alarm() - local location=system:location() - url="https://api.sunrise-sunset.org/json?lat="..location[1].."&lng="..location[2].."&date=today&formatted=1" - http:get(url) -end - - -function on_network_result(result) - local t = json.decode(result) - local table = { - { "sunrise:", date(t.results.sunrise):tolocal():fmt("%r") }, - { "sunset:", date(t.results.sunset):tolocal():fmt("%r") }, - } - ui:show_table(table, 2) -end \ No newline at end of file diff --git a/main/sunrise-sunset-widget.lua b/main/sunrise-sunset-widget.lua new file mode 100644 index 0000000..95a5667 --- /dev/null +++ b/main/sunrise-sunset-widget.lua @@ -0,0 +1,32 @@ +-- name = "Sunrise/Sunset" +-- description = "Shows Sunrise Sunset at your location" +-- data_source = "https://api.sunrise-sunset.org/" +-- type = "widget" +-- author = "Sriram S V" +-- version = "1.0" +-- foldable = "false" + +local json = require "json" +local date = require "date" +local fmt = require "fmt" + +function on_alarm() + local location=system:location() + local url="https://api.sunrise-sunset.org/json?lat="..location[1].."&lng="..location[2].."&date=today&formatted=1" + + http:get(url) +end + + +function on_network_result(result) + local t = json.decode(result) + + local sunrise_time = date(t.results.sunrise):tolocal():fmt("%H:%M") + local sunset_time = date(t.results.sunset):tolocal():fmt("%H:%M") + + ui:show_text( + aio:res_string("today", "Today")..":".. + fmt.space(4).."⬆"..fmt.space(2)..sunrise_time.. + fmt.space(4).."⬇"..fmt.space(2)..sunset_time + ) +end -- 2.43.0 From 52e27e22a0ef6fc52621d12271f6fb7607e62d7a Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 20 Sep 2023 19:12:53 +0400 Subject: [PATCH 055/204] Change contacts and apps modules APIs --- README.md | 28 +++++++++++++++++++--------- main/contacts-menu.lua | 15 +++++++-------- samples/apps-menu.lua | 9 +++------ 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index f170f9e..ca5d35c 100644 --- a/README.md +++ b/README.md @@ -343,14 +343,24 @@ end ## Application management -* `apps:list([sort_by], [no_hidden])` - returns the package table of all installed applications (if it is cloned app or Android for Work app package name will also contain user id, like that: `com.example.app:123`), `sort_by` - sort option (see below), `no_hidden` - true if no hidden applications are needed; -* `apps:name(package)` - returns application name; -* `apps:color(package)` - returns the color of the application in #XXXXXXXX format; +* `apps:apps([sort_by])` - returns the table of tables of all installed applications +, `sort_by` - sort option (see below); * `apps:launch(package)` - launches the application; * `apps:show_edit_dialog(package)` - shows edit dialog of the application; -* `apps:categories()` - returns a table of category tables; -* `apps:by_category(category_id)` - returns a table of application packages belonging to the specified category; -* `apps:request_icons(packages)` - requests icons for the specified list of applications, the result will be returned in the `on_icons_ready()` callback. +* `apps:categories()` - returns a table of category tables. + +The format of the apps table: + +``` +`pkg` - name of the app package (if it is cloned app or Android for Work app package name will also contain user id, like that: `com.example.app:123`); +`name` - name of the application; +`color` - application color; +`hidden` - true if the application is hidden; +`suspended` - true if the application is suspended; +`category_id` - category ID; +`badge` - number on the badge; +`icon` - icon of the application in the form of a link (can be used in the side menu scripts). +``` The format of the category table: @@ -427,8 +437,7 @@ The function `calendar:request_permission()` calls `on_permission_granted()` cal * `phone:make_call(number)` - dial the number in the dialer; * `phone:send_sms(number, [text])` - open SMS application and enter the number, optionally enter text; * `phone:show_contact_dialog(id|lookup_key)` - open contact dialog; -* `phone:open_contact(id)` - open contact in the contacts app; -* `phone:request_icons(cantact_ids)` - requests icons of contacts with specified IDs, the result will be in the `on_icons_ready` callback. +* `phone:open_contact(id)` - open contact in the contacts app. Contacts table format: @@ -436,7 +445,8 @@ Contacts table format: `id` - contact id; `lookup_key` - unique contact identifier; `name` - contact name; -`number` - contact number. +`number` - contact number; +`icon` - contact icon in the form of a link (can be used in the side menu scripts). ``` The function `phone:request_permission()` calls `on_permission_granted()` callback if the user agrees to grant permission. diff --git a/main/contacts-menu.lua b/main/contacts-menu.lua index e8cf773..f0b96d3 100644 --- a/main/contacts-menu.lua +++ b/main/contacts-menu.lua @@ -28,16 +28,15 @@ function on_drawer_open() names = map(contacts, function(it) return it.name end) keys = map(contacts, function(it) return it.lookup_key end) - icons = map(contacts, function(it) return it.name:sub(1,1) end) + icons = map(contacts, function(it) + if it.icon ~= nil then + return it.icon + else + return it.name:sub(1,1) -- Backward compatibility + end + end) drawer:show_list(names, icons, nil, true) - - -- Uncomment this if you want to use real icons (slow) - --phone:request_icons(keys) -end - -function on_icons_ready(icons) - drawer:show_list(names, icons, nil, true) end function on_click(idx) diff --git a/samples/apps-menu.lua b/samples/apps-menu.lua index 536bdf0..7d26e60 100644 --- a/samples/apps-menu.lua +++ b/samples/apps-menu.lua @@ -3,8 +3,7 @@ -- testing = "true" function on_drawer_open() - apps_tab = apps:list() - debug:toast("called") + apps_tab = apps:apps() -- Do not update if the list of the apps is not changed if #apps_tab ~= #drawer:items() then @@ -13,11 +12,9 @@ function on_drawer_open() end function update() - names_tab = map(function(it) return apps:name(it) end, apps_tab) - apps:request_icons(apps_tab) -end + names_tab = map(function(it) return it.name end, apps_tab) + icons_tab = map(function(it) return it.icon end, apps_tab) -function on_icons_ready(icons_tab) drawer:show_list(names_tab, icons_tab, nil, true) end -- 2.43.0 From 786f7521434e7f454e23ae4777231f474e4c5108 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 20 Sep 2023 19:13:15 +0400 Subject: [PATCH 056/204] Update zip --- scripts.index | 1 + scripts.md5 | 2 +- scripts.zip | Bin 21694 -> 22406 bytes 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts.index b/scripts.index index a20985b..1dea528 100644 --- a/scripts.index +++ b/scripts.index @@ -9,6 +9,7 @@ kodi-remote-widget.lua public-ip-widget.lua quotes-widget.lua shell-widget.lua +sunrise-sunset-widget.lua sys-info-widget.lua tasks-menu.lua unit-converter.lua diff --git a/scripts.md5 b/scripts.md5 index 6553deb..5514b97 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -71323911ba57c8db51356c2a3812998f +fc6a24023ff127b731915ea2446cdad7 diff --git a/scripts.zip b/scripts.zip index 75e6e9d61200e5943a2ae39785e42ea86e52af6e..4b36fcbd3777eb52ae45295e5a330f84815fef49 100644 GIT binary patch delta 6289 zcmZu#bzGF|68;ttmQLxG5(E)p=?0gO25FF#Tm*J$S!qzoMGz@T={As(F6mT2T1r|8 zLAbk~>-BK%`QzLDe)GLEZ#?hJJTr}jpzv}Kt+qNg4ix|ZU_eQU$M8k$X?h?C0CutB zX_=66xj$@GiwW!yK7;@WXB8U&e*Kv1OgXg*5^P{1xGbup zs{EreR$8*8B>UsXpgy3u2l(3p9b zd)+UjB7JC11@V~TqhDM);>zysAbTcqZVZ+}J1QQyJ*A1d$~R@_m>`U8SXs6lt^LYy zak(0&1^-pXi3uStnLJOy#!&MNh18uSXBOj8xer0@kpZPv_*IHAlRk_+bNQA_5>cc! ze6HC+8v0GR$i3j1^@Xdq47_^3FGQNk4lh1_K62~Z_=|T*&sT)UM~z~Qs|(9mk^H@U z4MgF*wpV-MAeQs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SnGp%y`tyx8_{nOm=A&^%_KDO>;)zD1A{Y3% zFm+k>5eaRV$Pr)4ljkxR#1=b8hn5j6v`#Xe-o4&34vAOSbDFB_@Zu?QZ1e-OcN3eA zBqsQCEqs#WJa9F9FPf~<#Fx5fasGH~Q)ps@(6gQ#hl><;27GA#KfDqy6CG^u@X|Ja z`H)p@bHiCHLgzF6&b@e>Tzf--#=JwnV2n$?q0f@Y^rR)l4RBD6R?dKq<;xY{at%w( zW11-}``4z}J=AV(pKLykx?m%{YWGfZol^JonwrC^+W4D@Z>V7*2W&P|uBI5~MuN5Z z>!jTptN3J1_Pzu=ZP)D+sYTsYML9Z?+HCh?2B4H=-${=Q_lW5FN~)NPvFz+IiKgYE(vG`ss-s{K~;a6KlV<>3Q^LX z+=Jv3d1_>zuP%r%IvZ~+S#)bVOc;cDY2A;o5Ta;3_arqkc-Fu4aMz}3$DW2oE!QTu zVP9N9@rjJMCi&<~n#B1yLWxwtWfLuG#+cdHtVzze_XM(l=u8L~_xLK4MF0jGrIl6R zo>Ba&F`F%Rase~%1gNftez{*H5fby?ZkB$=2 zUn?rT^8ft%UcVAd_4_;s8*V5J0R}?Y3PV=nvnfNrA)JW-K!U?94<|3jTRvhQez(l7 zlYk(==;4%$$_+KgDj6|DfHA}=FW3L}ro|-xv?6C(oHikpS3{s0z_unp=S%aO z7M@sDVr8@;;Y3HY*guSUAwYw2rrmF?2?Yqm@SBV*dJq{QaN~n6VWmOc0>r zIc2``Tdni|?0L)r0-;@(1yuJLLe0-gLMFjvlr@Sh^ z!_7a>azO+TfbvCpI{A3t_V)d!6#y`uS#g>OtvUVp03cLwKmgGGW<`MnmfegQ0wl?q zc4z5fWd`T;M1Vkdk?u&8lOyuhKScw1b0+#UYts6*-tGZW`U-Fe({G|} Date: Wed, 20 Sep 2023 19:19:43 +0400 Subject: [PATCH 057/204] Update changelog --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index ca5d35c..c1d5c49 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,12 @@ The type of script is determined by the line (meta tag) at the beginning of the # Changelog +### 4.9.0 + +* The `apps` module now has an `apps()` function that returns a table with app details, including the app icon; +* The `phone:contacts()` function now returns an icon that can be used in the side menu; +* The `apps:request_icons()` and `phone:request_icons()` functions are deprecated. + ### 4.8.0 * Side menu scripts support; -- 2.43.0 From 6fc61035765c414495dfd2ad708ef9f7b9aaa557 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 20 Sep 2023 19:41:19 +0400 Subject: [PATCH 058/204] Contacts menu bug fix --- main/contacts-menu.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main/contacts-menu.lua b/main/contacts-menu.lua index f0b96d3..85cad84 100644 --- a/main/contacts-menu.lua +++ b/main/contacts-menu.lua @@ -28,11 +28,12 @@ function on_drawer_open() names = map(contacts, function(it) return it.name end) keys = map(contacts, function(it) return it.lookup_key end) + icons = map(contacts, function(it) if it.icon ~= nil then return it.icon else - return it.name:sub(1,1) -- Backward compatibility + return "fa:phone" -- Backward compatibility end end) -- 2.43.0 From ac30702679285f83ae549f20880accc05a9c7115 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 20 Sep 2023 19:42:08 +0400 Subject: [PATCH 059/204] Update zip --- scripts.md5 | 2 +- scripts.zip | Bin 22406 -> 22405 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts.md5 b/scripts.md5 index 5514b97..584ed34 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -fc6a24023ff127b731915ea2446cdad7 +b4e2cc2aa0836b343b71d1c5181a8dd3 diff --git a/scripts.zip b/scripts.zip index 4b36fcbd3777eb52ae45295e5a330f84815fef49..7291ce2173728bb0c62f7350cf02a7dfdc79fadf 100644 GIT binary patch delta 802 zcmV+-1Ks?FuK|Ux0kED84IrH~SHghDyG;TB049^G4IO`s5({OF5({N@cnbgl1n2_* z00ig*0050t+lt#T5PkPo2=9vxPH3S}H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**hPn8zUAFgc#@PvIZ4Yx6qgy+KrJ7w^>G;x?d{Sd=F z+~ecg2KFco5P!lj*3TaHZamjT&G>tHX9WKMvn&uvKn)OlG*=1y;*m}Q001kKf>0|1 zPuL2RAyXWa%upTyEtBg|Q~|w{Kv7izOp}&TVgv9L0Fw+A8Iu%JKmjU~RZ>|2YLl;0 zRss2w22)i5c#~XHUIB5FyHi*J6q6KGQvtt|XjE4LIg`LtTLBW29935V){}HqSp&s8 r0F&W68 Date: Thu, 21 Sep 2023 15:56:41 +0400 Subject: [PATCH 060/204] Small fix --- community/settings-menu.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/community/settings-menu.lua b/community/settings-menu.lua index 203d63a..79d8c57 100644 --- a/community/settings-menu.lua +++ b/community/settings-menu.lua @@ -3,7 +3,7 @@ -- description = "Side menu with AIO settings" -- aio_version = "4.7.99" -- type = "drawer" --- author = "Evgeny Zobnin (zobnin@gmail.com) +-- author = "Evgeny Zobnin (zobnin@gmail.com)" -- version = "1.0" function on_drawer_open() -- 2.43.0 From 8570afbefa854b75e462d5d47cfffcba88d6e86e Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 1 Oct 2023 16:58:14 +0400 Subject: [PATCH 061/204] Add click listener to Country search script --- community/country-search.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/community/country-search.lua b/community/country-search.lua index 0622e02..c57572c 100644 --- a/community/country-search.lua +++ b/community/country-search.lua @@ -6,6 +6,8 @@ --- Original code: https://dev.fandom.com/wiki/Global_Lua_Modules/Country +local url = require("url") + function on_search(str) if str == nil then return end @@ -20,6 +22,10 @@ function on_search(str) end end +function on_click() + system:open_browser("https://google.com/search?q="..url.quote(result)) +end + function getCountryData(code, info) if info and code then -- if the code doesn't exist try looking for a country name -- 2.43.0 From b202daa621118abb7e85dc61c3f998bd0293e46c Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 1 Oct 2023 17:24:53 +0400 Subject: [PATCH 062/204] Move startpage script to defunct --- {community => defunct}/starpage-search.lua | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {community => defunct}/starpage-search.lua (100%) diff --git a/community/starpage-search.lua b/defunct/starpage-search.lua similarity index 100% rename from community/starpage-search.lua rename to defunct/starpage-search.lua -- 2.43.0 From 015252323a8ce22b5274905aafb9d4a62a2d9ab5 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 18 Oct 2023 09:02:16 +0400 Subject: [PATCH 063/204] Add sample --- samples/screen-state-widget.lua | 48 ------------------------------ samples/text-with-icons-sample.lua | 3 ++ 2 files changed, 3 insertions(+), 48 deletions(-) delete mode 100644 samples/screen-state-widget.lua create mode 100644 samples/text-with-icons-sample.lua diff --git a/samples/screen-state-widget.lua b/samples/screen-state-widget.lua deleted file mode 100644 index 5a3ec96..0000000 --- a/samples/screen-state-widget.lua +++ /dev/null @@ -1,48 +0,0 @@ --- name = "Screen state" - -local json = require "json" - -function on_resume() - ui:show_buttons{ - "Save screen", - "Restore screen", - } -end - -function on_click(idx) - if idx == 1 then - save_state() - else - restore_state() - end -end - -function save_state() - local state = aio:get_active_widgets() - local json_str = json.encode(state) - - files:write("screen-state", json_str) - ui:show_toast("Screen state saved!") -end - -function restore_state() - local json_str = files:read("screen-state") - local state = json.decode(json_str) - - remove_all_widgets() - - for k,v in pairs(state) do - aio:add_widget(v.name, v.position) - end - - ui:show_toast("Screen state restored!") -end - -function remove_all_widgets() - local curr_state = aio:get_active_widgets() - for k,v in pairs(curr_state) do - if (v.name ~= "screen-state-widget.lua") then - aio:remove_widget(v.position) - end - end -end diff --git a/samples/text-with-icons-sample.lua b/samples/text-with-icons-sample.lua new file mode 100644 index 0000000..c84c45a --- /dev/null +++ b/samples/text-with-icons-sample.lua @@ -0,0 +1,3 @@ +function on_resume() + ui:show_text("%%fa:cube%% This is text with icons %%fa:face-smile%% %%fa:poo%% and styles %%fa:cube%%") +end -- 2.43.0 From ad79c9a7d638a0aab605481037fb1c9267c8b22f Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 18 Oct 2023 09:08:27 +0400 Subject: [PATCH 064/204] Update README --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c1d5c49..d07be40 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,11 @@ The type of script is determined by the line (meta tag) at the beginning of the # Changelog +### 4.9.2 + +* The `apps` module now has an `app()` function that returns selected app table +* You can use `%%fa:ICON_NAME%%` tag in the any text to show FontAwesome icon inside the text + ### 4.9.0 * The `apps` module now has an `apps()` function that returns a table with app details, including the app icon; @@ -140,6 +145,12 @@ First line
Second line You can also use Markdown markup. To do this, add the prefix `%%mkd%%` to the beginning of the line. Or you can disable the formatting completely with the prefix `%%txt%%`. +You can insert FontAwesome icons inside the text, to do this use this syntax: `%%fa:ICON_NAME%%. For example: + +``` +ui:show_text("This is the text with icons %%fa:face-smile%% %%fa:poo%% and styles") +``` + The `ui:show_buttons()` function supports Fontawesome icons. Simply specify `fa:icon_name` as the button name, for example: `fa:play`. (Note: AIO only supports icons up to Fontawesome 6.3.0.) ## Dialogs @@ -349,7 +360,8 @@ end ## Application management -* `apps:apps([sort_by])` - returns the table of tables of all installed applications +* `apps:apps([sort_by])` - returns the table of tables of all installed applications; +* `apps:app(package_name)` - return the table of tables of the given application; , `sort_by` - sort option (see below); * `apps:launch(package)` - launches the application; * `apps:show_edit_dialog(package)` - shows edit dialog of the application; -- 2.43.0 From b3b57e12fa7f07d5827fecd42449a77beb1889e6 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 26 Oct 2023 18:45:47 +0400 Subject: [PATCH 065/204] Move conversations widget to the samples --- community/screen-state-menu.lua | 53 +++++++++++++++++++ .../conversations-widget.lua | 0 2 files changed, 53 insertions(+) create mode 100644 community/screen-state-menu.lua rename {community => samples}/conversations-widget.lua (100%) diff --git a/community/screen-state-menu.lua b/community/screen-state-menu.lua new file mode 100644 index 0000000..c433bb6 --- /dev/null +++ b/community/screen-state-menu.lua @@ -0,0 +1,53 @@ +-- name = "Screen state" +-- type = "drawer" + +local prefs = require "prefs" + +function on_drawer_open() + if prefs.states == nil then + prefs.states = {} + end + + update_screen() +end + +function update_screen() + local state_names = {} + + for k,v in pairs(prefs.states) do + table.insert(state_names, k) + end + + table.insert(state_names, "Save new state") + + drawer:show_list(state_names) +end + +function on_click(idx) + if idx > #prefs.states then + save_state("State") + else + restore_state(name) + end +end + +function save_state(name) + local state = aio:active_widgets() + prefs.states[name] = state + update_screen() +end + +function restore_state(name) + remove_all_widgets() + + for k,v in pairs(prefs.states[name]) do + aio:add_widget(v.name, v.position) + end +end + +function remove_all_widgets() + local curr_state = aio:active_widgets() + for k,v in pairs(curr_state) do + aio:remove_widget(v.position) + end +end diff --git a/community/conversations-widget.lua b/samples/conversations-widget.lua similarity index 100% rename from community/conversations-widget.lua rename to samples/conversations-widget.lua -- 2.43.0 From fe13d7d708406811d1aa65d262d21a3a08972ea2 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 10 Nov 2023 17:17:06 +0400 Subject: [PATCH 066/204] Update Quick Actions script --- community/quickactions-widget.lua | 129 ++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 community/quickactions-widget.lua diff --git a/community/quickactions-widget.lua b/community/quickactions-widget.lua new file mode 100644 index 0000000..3540c81 --- /dev/null +++ b/community/quickactions-widget.lua @@ -0,0 +1,129 @@ +-- name = "Quick Actions" +-- type = "widget" +-- description = "Launcher selected actions widget" +-- arguments_help = "Long click button for options, open widget settings for list of buttons" +--foldable = "true" +-- author = "Theodor Galanis" +-- version = "2.0" + +md_colors = require "md_colors" + +local icons = { "fa:pen", "fa:edit", "fa:indent", "fa:bars", "fa:sliders-h", "fa:redo", "fa:power-off", "fa:bring-forward", "fa:eraser", "fa:tools", "fa:layer-minus", "fa:layer-group", "fa:user-shield", "fa:lock", "fa:chevron-down", "fa:chevron-up", "fa:notes-medical", "fa:circle-r", "fa:envelope", "fa:square-full", "fa:microphone", "fa:search"} + +local names = {"Menu", "Quick Menu", "Side Menu", "Widget Titles", "Settings", "Refresh launcher", "Restart launcher", "Notifications", "Clear Norifications", "Control center", "Fold all widgets", "Unfold all widgets", "Private mode", "Screen off", "Scroll down", "Scroll up", "Add note", "Record", "Send mail", "Show recents", "Assistant", "Search"} + +local colors = { md_colors.purple_800, md_colors.purple_600, md_colors.amber_900, md_colors.orange_900, md_colors.blue_900, md_colors.deep_purple_800, md_colors.red_900, md_colors.green_900, md_colors.green_700, md_colors.blue_800, md_colors.pink_300, md_colors.pink_A200, md_colors.green_600, md_colors.grey_800, md_colors.teal_700, md_colors.teal_800, md_colors.lime_800, md_colors.red_800, md_colors.deep_orange_900, md_colors.deep_purple_700, md_colors.blue_700, md_colors.blue_grey_700} + + local actions = { "quick_menu", "quick_apps_menu", "apps_menu", "headers", "settings", "refresh", "restart", "notify", "clear_notifications", "quick_settings", "fold", "unfold", "private_mode", "screen_off", "scroll_down", "scroll_up", "add_note", "start_record", "send_mail", "show_recents", "voice", "search"} + +local pos = 0 + +function on_resume() + if next(settings:get()) == nil then + set_default_args() + set_default_cols() + end + local buttons,colors = get_buttons() + ui:show_buttons(buttons, colors) +end + +function on_click(idx) + pos = idx + redraw() +end + +function on_long_click(idx) + pos = idx + local tab = settings:get() + ui:show_context_menu({{"angle-left",""},{"ban",""},{"angle-right",""},{icons[get_checkbox_idx()[idx]]:gsub("fa:",""),names[get_checkbox_idx()[idx]]}}) +end + +function on_context_menu_click(menu_idx) + if menu_idx == 1 then + move(-1) + elseif menu_idx == 2 then + remove() + elseif menu_idx == 3 then + move(1) + elseif menu_idx == 4 then + redraw() + end +end + +function on_dialog_action(data) + if data == -1 then + return + end + settings:set(data) + on_resume() +end + +function on_settings() + ui:show_checkbox_dialog("Select actions", names, get_checkbox_idx()) +end + +--utilities-- + +function redraw() + local buttons,colors = get_buttons() + local checkbox_idx = get_checkbox_idx() + local action = actions[checkbox_idx[pos]] +aio:do_action(action) + ui:show_buttons(buttons, colors) +end + +function set_default_args() + local args = {} + for i = 1, #actions do + table.insert(args, i) + end + settings:set(args) +end + +function set_default_cols() + local cols = {} + for i = 1, #colors do + table.insert(cols, i) + end + settings:set(cols) +end + +function get_checkbox_idx() + local tab = settings:get() + for i = 1, #tab do + tab[i] = tonumber(tab[i]) + end + return tab +end + +function get_buttons() + local buttons,bcolors = {},{} + local checkbox_idx = get_checkbox_idx() + for i = 1, #checkbox_idx do + table.insert(buttons, icons[checkbox_idx[i]]) + table.insert(bcolors, colors[checkbox_idx[i]]) + end + return buttons,bcolors +end + +function move(x) + local tab = settings:get() + if (pos == 1 and x < 0) or (pos == #tab and x > 0) then + return + end + local cur = tab[pos] + local prev = tab[pos+x] + tab[pos+x] = cur + tab[pos] = prev + settings:set(tab) + local buttons,colors = get_buttons() + ui:show_buttons(buttons, colors) +end + +function remove() + local tab = settings:get() + table.remove(tab,pos) + settings:set(tab) + local buttons,colors = get_buttons() + ui:show_buttons(buttons, colors) +end \ No newline at end of file -- 2.43.0 From b563f67867bf2a3893569db4dd0a28a7b8c29129 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 19 Nov 2023 13:24:24 +0400 Subject: [PATCH 067/204] Add ChatGPT search script --- community/chatgpt-search.lua | 70 ++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 community/chatgpt-search.lua diff --git a/community/chatgpt-search.lua b/community/chatgpt-search.lua new file mode 100644 index 0000000..c834947 --- /dev/null +++ b/community/chatgpt-search.lua @@ -0,0 +1,70 @@ +-- name = "ChatGPT" +-- description = "A search script that allows you to task with ChatGPT" +-- data_source = "openai.com" +-- type = "search" +-- author = "Evgeny Zobnin" +-- version = "1.0" + +local json = require "json" + +-- constants +local ok_color = aio:colors().primary_text +local error_color = aio:colors().progress_bad +local uri = "https://ai.fakeopen.com/v1/chat/completions" +local key = "pk-this-is-a-real-free-pool-token-for-everyone" + +-- vars +local question = "" +local answer = "" + +local payload_template = [[ +{ + "model": "gpt-3.5-turbo", + "temperature": 0.8, + "max_tokens": 100, + "messages": [ + { + "role": "user", + "content": "%%Q%%. Answer in one sentence." + } + ] +} +]] + +function on_search(input) + search:show_lines({"Ask ChatGPT: \""..input.."\""}, {ok_color}, true) + question = input + answer = "" +end + +function on_click() + if answer == "" then + search:show_lines({"Waiting for answer..."}, {ok_color}, true) + make_request(question) + return false + else + system:copy_to_clipboard(answer) + return true + end +end + +function make_request(str) + local payload = payload_template:replace("%%Q%%", str) + + http:set_headers{ "Authorization: Bearer "..key } + http:post(uri, payload, "application/json") +end + +function on_network_result(result, code) + if code >= 200 and code < 300 then + answer = get_answer(result) + search:show_lines({answer}, {ok_color}, true) + else + search:show_lines({"Server error: "..code}, {error_color}, true) + end +end + +function get_answer(result) + local t = json.decode(result) + return t.choices[1].message.content +end -- 2.43.0 From e3aaf8b6f1469d5985c3cfd91f66dfb11a2f026b Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 19 Nov 2023 13:25:02 +0400 Subject: [PATCH 068/204] Update quick actions script --- community/quickactions-widget.lua | 46 ++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/community/quickactions-widget.lua b/community/quickactions-widget.lua index 3540c81..0c0ddd2 100644 --- a/community/quickactions-widget.lua +++ b/community/quickactions-widget.lua @@ -4,24 +4,23 @@ -- arguments_help = "Long click button for options, open widget settings for list of buttons" --foldable = "true" -- author = "Theodor Galanis" --- version = "2.0" +-- version = "2.5" md_colors = require "md_colors" -local icons = { "fa:pen", "fa:edit", "fa:indent", "fa:bars", "fa:sliders-h", "fa:redo", "fa:power-off", "fa:bring-forward", "fa:eraser", "fa:tools", "fa:layer-minus", "fa:layer-group", "fa:user-shield", "fa:lock", "fa:chevron-down", "fa:chevron-up", "fa:notes-medical", "fa:circle-r", "fa:envelope", "fa:square-full", "fa:microphone", "fa:search"} +local icons = { "fa:pen", "fa:edit", "fa:indent", "fa:bars", "fa:sliders-h", "fa:redo", "fa:power-off", "fa:bring-forward", "fa:eraser", "fa:tools", "fa:layer-minus", "fa:layer-group", "fa:user-shield", "fa:lock", "fa:chevron-down", "fa:chevron-up", "fa:notes-medical", "fa:circle-dot", "fa:envelope", "fa:square-full", "fa:microphone", "fa:hand", "fa:search"} -local names = {"Menu", "Quick Menu", "Side Menu", "Widget Titles", "Settings", "Refresh launcher", "Restart launcher", "Notifications", "Clear Norifications", "Control center", "Fold all widgets", "Unfold all widgets", "Private mode", "Screen off", "Scroll down", "Scroll up", "Add note", "Record", "Send mail", "Show recents", "Assistant", "Search"} +local names = {"Quick menu", "Quick apps menu", "Applications menu", "Toggle headers", "Settings", "Screen refresh", "Restart AIO launcher", "Notifications panel", "Clear notifications", "Quick settings", "Fold all widgets", "Unfold all widgets", "Private mode", "Screen off", "Scroll down", "Scroll up", "Add note", "Start audio recording", "Send mail", "Recent apps", "Voice command", "One-handed mode", "Search"} -local colors = { md_colors.purple_800, md_colors.purple_600, md_colors.amber_900, md_colors.orange_900, md_colors.blue_900, md_colors.deep_purple_800, md_colors.red_900, md_colors.green_900, md_colors.green_700, md_colors.blue_800, md_colors.pink_300, md_colors.pink_A200, md_colors.green_600, md_colors.grey_800, md_colors.teal_700, md_colors.teal_800, md_colors.lime_800, md_colors.red_800, md_colors.deep_orange_900, md_colors.deep_purple_700, md_colors.blue_700, md_colors.blue_grey_700} +local colors = { md_colors.purple_800, md_colors.purple_600, md_colors.amber_900, md_colors.orange_900, md_colors.blue_900, md_colors.deep_purple_800, md_colors.grey_600, md_colors.green_900, md_colors.green_900, md_colors.blue_800, md_colors.pink_300, md_colors.pink_A200, md_colors.green_600, md_colors.grey_800, md_colors.teal_700, md_colors.teal_800, md_colors.orange_700, md_colors.red_800, md_colors.red_900, md_colors.deep_purple_700, md_colors.blue_700, md_colors.amber_800, md_colors.blue_grey_700} - local actions = { "quick_menu", "quick_apps_menu", "apps_menu", "headers", "settings", "refresh", "restart", "notify", "clear_notifications", "quick_settings", "fold", "unfold", "private_mode", "screen_off", "scroll_down", "scroll_up", "add_note", "start_record", "send_mail", "show_recents", "voice", "search"} + local actions = { "quick_menu", "quick_apps_menu", "apps_menu", "headers", "settings", "refresh", "restart", "notify", "clear_notifications", "quick_settings", "fold", "unfold", "private_mode", "screen_off", "scroll_down", "scroll_up", "add_note", "start_record", "send_mail", "show_recents", "voice", "one_handed", "search"} local pos = 0 function on_resume() if next(settings:get()) == nil then set_default_args() - set_default_cols() end local buttons,colors = get_buttons() ui:show_buttons(buttons, colors) @@ -35,7 +34,11 @@ end function on_long_click(idx) pos = idx local tab = settings:get() - ui:show_context_menu({{"angle-left",""},{"ban",""},{"angle-right",""},{icons[get_checkbox_idx()[idx]]:gsub("fa:",""),names[get_checkbox_idx()[idx]]}}) + label = get_label(actions[get_checkbox_idx()[idx]]) + if label == nil then + label = names[get_checkbox_idx()[idx]] + end + ui:show_context_menu({{"angle-left",""},{"ban",""},{"angle-right",""},{icons[get_checkbox_idx()[idx]]:gsub("fa:",""),label}}) end function on_context_menu_click(menu_idx) @@ -59,7 +62,17 @@ function on_dialog_action(data) end function on_settings() - ui:show_checkbox_dialog("Select actions", names, get_checkbox_idx()) +axions = aio:actions() +lab = {} +for i = 1, #axions do +lav = get_label(actions[i]) + if lav == nil then + table.insert(lab,names[i]) + else + table.insert(lab, lav) + end + end + ui:show_checkbox_dialog("Select actions", lab, get_checkbox_idx()) end --utilities-- @@ -80,14 +93,6 @@ function set_default_args() settings:set(args) end -function set_default_cols() - local cols = {} - for i = 1, #colors do - table.insert(cols, i) - end - settings:set(cols) -end - function get_checkbox_idx() local tab = settings:get() for i = 1, #tab do @@ -126,4 +131,13 @@ function remove() settings:set(tab) local buttons,colors = get_buttons() ui:show_buttons(buttons, colors) +end + +function get_label(name) +axions = aio:actions() + for _, action in ipairs(axions) do + if action["name"] == name then + return action["label"] + end + end end \ No newline at end of file -- 2.43.0 From 36ed0c728886a1e8206b140776db5ae7ef87fee1 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 24 Nov 2023 09:05:13 +0400 Subject: [PATCH 069/204] Update README --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d07be40..da03285 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,11 @@ The type of script is determined by the line (meta tag) at the beginning of the # Changelog +### 4.9.4 + +* The `aio:actions()` function now also returns arguments format for each action +* Added function `system:format_date_localized()` + ### 4.9.2 * The `apps` module now has an `app()` function that returns selected app table @@ -273,6 +278,7 @@ The function takes a command table of this format as a parameter: * `system:lang()` - returns the language selected in the system; * `system:tz_offset()` - returns TimeZone offset in seconds; * `system:currency()` - returns default currency code based on locale; +* `system:format_date_localized(format, date)` - returns localized date string (using java formatting); * `system:battery_info()` - returns table with battery info; * `system:system_info()` - returns table with system info. @@ -335,7 +341,8 @@ Format of table elements returned by `aio:actions()`: ``` `name` - action name; `short_name` - action short name; -`label` - action name visible to the user. +`label` - action name visible to the user; +`args` - action arguments if any. ``` To accept a value sent by the `send_message` function, the receiving script must implement a callback `on_message(value)`. -- 2.43.0 From 89199971060366c921f2fefa70a818b2ebd70b5c Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 5 Jan 2024 09:24:16 +0400 Subject: [PATCH 070/204] mv chatgpt script to defunct --- {community => defunct}/chatgpt-search.lua | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {community => defunct}/chatgpt-search.lua (100%) diff --git a/community/chatgpt-search.lua b/defunct/chatgpt-search.lua similarity index 100% rename from community/chatgpt-search.lua rename to defunct/chatgpt-search.lua -- 2.43.0 From ce9bc66b71eff11a24c79622be85890f0a683b1d Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 21 Feb 2024 08:53:20 +0400 Subject: [PATCH 071/204] Add jepardy widget sample --- samples/jepardy-widget.lua | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 samples/jepardy-widget.lua diff --git a/samples/jepardy-widget.lua b/samples/jepardy-widget.lua new file mode 100644 index 0000000..33c0807 --- /dev/null +++ b/samples/jepardy-widget.lua @@ -0,0 +1,43 @@ +--[[ + +This script is getnerated by ChatGPT + +Prompt:Search the internet for examples of scripts for AIO Launcher and write a script named "Jepardy" that will display a question from its database of questions with three answer options on the screen. If the answer is correct, a toast "Correct!" should appear on the screen, and a new question should be displayed. If the answer is incorrect, display a toast "Not correct" and present a new question. The database should contain questions in English. + +--]] + +-- A simplified structure for the questions database +local questions = { + { question = "What is the capital of France?", answers = {"London", "Berlin", "Paris"}, correct = 3 }, + { question = "What element does 'O' represent on the periodic table?", answers = {"Gold", "Oxygen", "Osmium"}, correct = 2 }, + -- Add more questions to reach 100. Each question is a table with the question text, + -- an array of answers, and the index of the correct answer in the array. +} + +local currentQuestionIndex = 1 -- Track the current question + +-- Function to display the current question and answers +function showCurrentQuestion() + local q = questions[currentQuestionIndex] + ui:show_lines({q.question, "1) " .. q.answers[1], "2) " .. q.answers[2], "3) " .. q.answers[3]}) +end + +-- Function to handle user's answer, check if it's correct, and move to the next question +function on_click(index) + local correctAnswer = questions[currentQuestionIndex].correct + 1 -- Adjust for 1-based indexing + if index == correctAnswer then + ui:show_toast("Correct!") + else + ui:show_toast("Not correct") + end + + -- Move to the next question, loop back to the first after the last question + currentQuestionIndex = (currentQuestionIndex % #questions) + 1 + showCurrentQuestion() +end + +-- Function called by AIO Launcher to resume the script/widget +function on_resume() + showCurrentQuestion() +end + -- 2.43.0 From 87c481a558b6f3997cb9a2fa35359424386c6837 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 21 Feb 2024 08:53:32 +0400 Subject: [PATCH 072/204] Update README --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index da03285..0818ba4 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,11 @@ The type of script is determined by the line (meta tag) at the beginning of the # Changelog +### 5.1.0 + +* Added `add_purchase` action +* Added `on_contacts_loaded()` callback + ### 4.9.4 * The `aio:actions()` function now also returns arguments format for each action @@ -476,6 +481,8 @@ Contacts table format: The function `phone:request_permission()` calls `on_permission_granted()` callback if the user agrees to grant permission. +Upon the first launch of the application, contacts may not yet be loaded, so in the scripts, you can use the `on_contacts_loaded()` callback, which will be called after the contacts are fully loaded. + ## Tasks _Avaialble from: 4.8.0_ -- 2.43.0 From adcdedea378a93081c8d595991bf85f25465c33a Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 15 Mar 2024 08:07:34 +0400 Subject: [PATCH 073/204] Add 'widgets' module to intercat with Android widgets --- README.md | 16 ++- README_APP_WIDGETS.md | 130 ++++++++++++++++++++++ community/chrome-shortctus-app-widget.lua | 41 +++++++ community/todoist-app-widget.lua | 119 ++++++++++++++++++++ samples/android-widget-dumper.lua | 53 +++++++++ samples/android-widget-sample.lua | 69 ++++++++++++ samples/android-widget-sample2.lua | 56 ++++++++++ samples/android-widget-sample3.lua | 46 ++++++++ 8 files changed, 525 insertions(+), 5 deletions(-) create mode 100644 README_APP_WIDGETS.md create mode 100644 community/chrome-shortctus-app-widget.lua create mode 100644 community/todoist-app-widget.lua create mode 100644 samples/android-widget-dumper.lua create mode 100644 samples/android-widget-sample.lua create mode 100644 samples/android-widget-sample2.lua create mode 100644 samples/android-widget-sample3.lua diff --git a/README.md b/README.md index 0818ba4..27a7c6a 100644 --- a/README.md +++ b/README.md @@ -604,19 +604,25 @@ _Avaialble from: 4.1.3_ All files are created in the subdirectory `/sdcard/Android/data/ru.execbit.aiolauncher/files/scripts` without ability to create subdirectories. +## App widgets + +Starting from version 5.2.0, AIO Launcher supports interaction with app widgets through scripts. This means that you can create a wrapper for any app's widget that will fully match the appearance and style of AIO. You can also use this API if you need to retrieve information from other applications, such as the balance on your mobile phone account or your car's parking spot. If the application has a widget providing such information, you will be able to access it. + +[Detailed instructions](README_APP_WIDGETS.md) + ## Settings -_Deprecated in 4.7.4. Use prefs module._ +_Deprecated in 4.7.4. Use Preferences module._ -* `settings:get()` - returns the settings table in an array of words format; +~~* `settings:get()` - returns the settings table in an array of words format; * `settings:set(table)` - saves the settings table in an array of words format; * `settings:get_kv()` - returns the settings table in `key=value` format; * `settings:set_kv(table)` - saves settings table in the format `key=value`; -* `settings:show_dialog()` - show settings change dialog. +* `settings:show_dialog()` - show settings change dialog.~~ -User can change settings through the dialog, which is available by clicking on the "gear" in the edit menu of the widget. If in the widget metadata there is a field `arguments_help`, its value will be shown in the edit dialog. If there is a field `arguments_default` - it will be used to get default arguments. +~~User can change settings through the dialog, which is available by clicking on the "gear" in the edit menu of the widget. If in the widget metadata there is a field `arguments_help`, its value will be shown in the edit dialog. If there is a field `arguments_default` - it will be used to get default arguments.~~ -The standard edit dialog can be replaced by your own if you implement the `on_settings()` function. +~~The standard edit dialog can be replaced by your own if you implement the `on_settings()` function.~~ ## Preferences diff --git a/README_APP_WIDGETS.md b/README_APP_WIDGETS.md new file mode 100644 index 0000000..f270968 --- /dev/null +++ b/README_APP_WIDGETS.md @@ -0,0 +1,130 @@ +Starting from version 5.2.0, AIO Launcher supports interaction with app widgets through scripts. This means that you can create a wrapper for any app's widget that will fully match the appearance and style of AIO. You can also use this API if you need to retrieve information from other applications, such as the balance on your mobile phone account or your car's parking spot. If the application has a widget providing such information, you will be able to access it. + +### Introduction + +Before you start working with app widgets, you need to find out the app widget provider's name and the widget interface structure. Both can be done using the [android-widget-dumper.lua](samples/android-widget-dumper.lua) script. Enter the package name of the desired application in its global variable `app_pkg` and run the script. It will display all the widgets available for that application. Click on the widget name, and you will see its provider name (first line) and a tree-like structure of its UI. Click on the text to copy it. + +Take, for example, The Weather Channel app (package name: `com.weather.Weather`). Install this app and add its package name to the dumper script. After running the dumper, it will show you a list of widgets. Click on "Widget 2x2". A widget configuration screen will open. Click Done at the top of the configurator screen, and you will see the data of this widget. The first line will be the provider's name: + +``` +com.weather.Weather/com.weather.Weather.widgets.WeatherWidgetProvider2x2 +``` + +The second block of information is the widget interface structure: + +``` +relative_layout_1: + image_1: #13356F + relative_layout_2: + image_2: 270x270 + text_1: 40° + text_2: Paris, France + text_3: Weather data not available +``` + +You can see that the widget contains two images and three text fields: `text_1`, `text_2`, `text_3`. The first two contain the information we need: temperature and location. + +Now we have everything to write our own widget that will use information from The Weather Channel widget and display it in a format convenient for us! + +### Writing a Widget Wrapper + +Let's start by writing a widget initialization function: + +``` +function setup_app_widget() + local id = widgets:setup("com.weather.Weather/com.weather.Weather.widgets.WeatherWidgetProvider2x2") + if (id ~= nil) then + prefs.wid = id + else + ui:show_text("Can't add widget") + end +end +``` + +Using the `widgets:setup()` method, we ask the launcher to prepare a widget for us. The method returns an identifier needed to work with the widget, or `nil` if an error occurred. Note that this function may trigger the widget's configuration window if it has one. + +Having obtained the identifier, we can use it to communicate with the widget. For this purpose, we call the `widgets:request_updates()` method: + +``` +widgets:request_updates(prefs.wid) +``` + +This method prepares the widget and then calls the `on_widget_updated(bridge)` callback every time the widget updates. The `bridge` object here is the main "window" or "bridge" for interacting with the widget. It's with its help that we will extract information from the widget. + +The most straightforward way to do this is to use the `bridge:dump_table()` method, which returns the same UI element hierarchy as the dumper script but in a Lua table format. Here's how we can use it to extract the strings we need and display them on the screen: + +``` +function on_app_widget_updated(bridge) + local tab = bridge:dump_table() + temp = tab.relative_layout_1.relative_layout_2.text_1 + location = tab.relative_layout_1.relative_layout_2.text_2 + + if location ~= nil and temp ~= nil then + ui:show_text(location..": "..temp) + end +end +``` + +Run the example [android-widget-sample2.lua](samples/android-widget-sample2.lua) to see how it looks on the screen. + +Another way to extract the same information is to use the `bridge:dump_strings()` method: + +``` +function on_app_widget_updated(bridge) + strings = bridge:dump_strings().values + temp = strings[1] + location = strings[2] + + if location ~= nil and temp ~= nil then + ui:show_text(location..": "..temp) + end +end +``` + +It returns a table of tables, where the `keys` table is an array of UI text elements, and `values` contains the text strings within them. You can use whichever method suits you better. + +In both cases, the strings can include HTML tags (``, ``, ``, ``) if the corresponding styles were applied to the text in the widget. + +### Handling Clicks + +Extracting information from an app widget is only half the job. Most widgets are interactive, meaning you can click on them to get some response, like adding a new note or opening a currency exchange rate window. + +Implementing clicks on widget elements from the script is very simple: just use the `bridge:click()` method, passing it the name of the UI element or the string it contains as an argument: + +``` +bridge:click(temp) +``` + +Open the example [android-widget-sample2.lua](samples/android-widget-sample2.lua) to see how this can be used in the script. + +### Updating and releasing the Widget + +The AIO Launcher widget API is designed to keep the widget in memory all the time while the script is on the screen. This means that after calling `widgets:request_updates()`, the launcher will call the `on_widget_updated()` callback after _every_ widget interface update as long as the script is on the launcher's screen, and the launcher is on the phone's screen. + +In most cases, such a mechanism is preferable. However, there are situations when `on_widget_updated()` should only be called when the script asks for it, and the widget itself should not constantly hang in memory. For this, there's a special `bridge:free()` method. + +For example, you have a widget whose information you want to receive every morning, not with every update. In this case, you do everything the same as in the example above, but at the end of the `on_app_widget_updated()` function, you call `bridge:free()`. After that, the launcher will release the widget and will no longer call the `on_widget_updated()` method (while the widget itself will not respond to clicks). Then, it's enough to call `widgets:request_updates()` every morning to update the script's content. + +### Other Functions + +The information provided above is sufficient to handle almost any application widget. However, to write a truly efficient script, you'll need a few more auxiliary functions: + +* `widgets:bound(id)` - returns true if the specified widget identifier was previously initialized using `widgets:setup()`. You should _always_ call this function at the beginning of the script and call `widgets:setup()` only if it returns `false`. + +* `bridge:color(element_name)` - returns the color of an element in the format `#000000`. With this method, you can find out the color of the text, the background color of the layout (if set), or even extract the primary color from an image. + +Other functions: + +``` +* bridge:label() - returns the name of the widget; +* bridge:provider() - returns the name of the widget provider; +* bridge:dump_tree() - returns the UI tree in text format; +* bridge:dump_json() - returns the UI tree in Json format; +* bridge:dump_colors() - returns a table of color tables, where `keys` are element names, `values` are colors; +* bridge:dump_elements(element_name) - returns a table of tables of specified elements, where `keys` are element names, `values` are their values. +``` + +### Examples + +In the [samples](samples/) directory, you will find several widget examples. Also, pay attention to the Todoist and Chrome widgets in the [community](community/) directory. + diff --git a/community/chrome-shortctus-app-widget.lua b/community/chrome-shortctus-app-widget.lua new file mode 100644 index 0000000..8f117a5 --- /dev/null +++ b/community/chrome-shortctus-app-widget.lua @@ -0,0 +1,41 @@ +-- name = "Chrome shortcuts" +-- description = "AIO wrapper for the Chrome shortcuts app widget" +-- type = "widget" +-- author = "Evgeny Zobnin (zobnin@gmail.com)" +-- version = "1.0" +-- foldable = "false" +-- uses_app: "com.android.chrome" + +local prefs = require "prefs" +prefs._name = "chrome" + +local buttons_labels = {"fa:magnifying-glass", "fa:microphone", "fa:hat_cowboy_side", "fa:camera", "fa:gamepad"} +local buttons_targets = {"h_layout_2", "image_2", "image_3", "image_4", "image_5"} +local w_bridge = nil + +function on_resume() + if not widgets:bound(prefs.wid) then + setup_app_widget() + end + + widgets:request_updates(prefs.wid) +end + +function on_app_widget_updated(bridge) + w_bridge = bridge + ui:show_buttons(buttons_labels) +end + +function on_click(idx) + w_bridge:click(buttons_targets[idx]) +end + +function setup_app_widget() + local id = widgets:setup("com.android.chrome/org.chromium.chrome.browser.quickactionsearchwidget.QuickActionSearchWidgetProvider$QuickActionSearchWidgetProviderSearch") + if (id ~= nil) then + prefs.wid = id + else + ui:show_text("Can't add widget") + return + end +end diff --git a/community/todoist-app-widget.lua b/community/todoist-app-widget.lua new file mode 100644 index 0000000..9675c20 --- /dev/null +++ b/community/todoist-app-widget.lua @@ -0,0 +1,119 @@ +-- name = "Todoist" +-- description = "AIO wrapper for the official Todoist app widget" +-- type = "widget" +-- author = "Andey Gavrilov" +-- aio_version = "4.1.99" +-- uses_app = "com.todoist" + +local prefs = require "prefs" +local fmt = require "fmt" + +local curr_tab = {} +local w_bridge = nil +local colors = {} + +function on_resume() + if not widgets:bound(prefs.wid) then + setup_app_widget() + end + widgets:request_updates(prefs.wid) +end + +function on_app_widget_updated(bridge) + w_bridge = bridge + colors = bridge:dump_colors() + curr_tab = parse(bridge:dump_table()) + ui:show_lines(curr_tab.lines) +end + +function parse(t) + local tab = {} + tab["list"] = t.v_layout_1.frame_layout_1.relative_layout_1.text_1 + local footer = t.v_layout_1.frame_layout_2 + for k,v in pairs(footer) do + if k:sub(1,8) == "relative" then + footer = v + break + end + end + local images = {} + local texts = {} + local lines = {} + local tasks = t.v_layout_1.frame_layout_2.list_layout_1 + if tasks == nil then tasks = {} end + local tkeys = {} + for k,v in pairs(tasks) do + table.insert(tkeys,k) + end + table.sort(tkeys) + for i1,v1 in ipairs(tkeys) do + for k2,v2 in pairs(tasks[v1]) do + for k3,v3 in pairs(v2) do + if k3:sub(1,5) == "image" then + table.insert(images,k3) + elseif k3:sub(1,8) == "v_layout" then + local text = "" + local subtexts = {} + for k4,v4 in pairs(v3) do + if k4:sub(1,4) == "text" then + table.insert(texts,v4) + text = v4 + local color = colors[images[#texts]] + if color ~= "#909090" and color then + text = fmt.colored(fmt.bold(text),color) + end + elseif k4:sub(1,8) == "h_layout" then + subtexts = recursion(v4,subtexts,#subtexts,false) + end + end + table.insert(lines,text..table.concat(subtexts)) + end + end + end + end + for k1,v1 in pairs(footer) do + for k2,v2 in pairs(v1) do + if k2:sub(1,4) == "text" then + table.insert(images,k2) + table.insert(texts,v2) + table.insert(lines,fmt.secondary("Add task")) + break + end + end + end + tab["images"] = images + tab["texts"] = texts + tab["lines"] = lines + return tab +end + +function recursion(t,tab,idx,flag) + for k,v in pairs(t) do + if k:sub(1,4) == "text" then + local a,b = v:match("(%d+)/(%d+)") + if a or flag then + table.insert(tab,idx,fmt.secondary(" - ") .. fmt.colored(v,colors[k])) + end + elseif k:sub(1,8) == "h_layout" then + tab = recursion(v,tab,1,true) + end + end + return tab +end + +function on_click(idx) + w_bridge:click(curr_tab.texts[idx]) +end + +function setup_app_widget() + local id = widgets:setup("com.todoist/com.todoist.appwidget.provider.ItemListAppWidgetProvider") + if (id ~= nil) then + prefs.wid = id + else + ui:show_text("Can't add widget") + end +end + +function on_settings() + w_bridge:click(curr_tab.list) +end diff --git a/samples/android-widget-dumper.lua b/samples/android-widget-dumper.lua new file mode 100644 index 0000000..b0b89e1 --- /dev/null +++ b/samples/android-widget-dumper.lua @@ -0,0 +1,53 @@ +-- name = "Android widgets dumper" + +-- Place app package name with widget here +app_pkg = "com.weather.Weather" +--app_pkg = "com.google.android.apps.tasks" +--app_pkg = "com.android.chrome" +--app_pkg = "com.whatsapp" + +-- Globals +labels = {} +providers = {} +dump = "" +wid = -1 + +function on_resume() + local list = widgets:list(app_pkg) + + if list == nil then + ui:show_text("Error: No widgets") + return + end + + labels = map(function(it) return it.label end, list) + providers = map(function(it) return it.provider end, list) + + w_content = "" + + if wid < 0 then + ui:show_lines(labels) + else + widgets:request_updates(wid) + end +end + +function on_click(idx) + if w_content == "" then + wid = widgets:setup(providers[idx]) + widgets:request_updates(wid) + else + system:copy_to_clipboard(w_content) + end +end + +function on_app_widget_updated(bridge) + local provider = bridge:provider() + local dump = bridge:dump_tree() + local colors = bridge:dump_colors() + w_content = provider.."\n\n"..dump.."\n\n"..serialize(colors) + + ui:show_text("%%txt%%"..w_content) + debug:log("dump:\n\n"..w_content) +end + diff --git a/samples/android-widget-sample.lua b/samples/android-widget-sample.lua new file mode 100644 index 0000000..c156007 --- /dev/null +++ b/samples/android-widget-sample.lua @@ -0,0 +1,69 @@ +-- name = "Android widgets sample (Gmail)" + +local prefs = require "prefs" + +local max_mails = 1 +local curr_tab = {} +local w_bridge = nil + +function on_resume() + if not widgets:bound(prefs.wid) then + setup_app_widget() + end + + widgets:request_updates(prefs.wid) +end + +function on_app_widget_updated(bridge) + local tab = bridge:dump_strings().values + + -- Removing redunant elements like widget title + tab = skip(tab, 4) + + -- Each mail consists of 4 text elements: + -- 1. from, 2. time, 3. subject, 4. text + tab = take(tab, max_mails * 4) + + -- Concatenate "from" and "time" + tab = concat(tab, {1, 2}, ", ") + + curr_tab = tab + w_bridge = bridge + + ui:show_lines(tab) +end + +function on_click(idx) + w_bridge:click(curr_tab[idx]) +end + +function setup_app_widget() + local id = widgets:setup("com.google.android.gm/com.google.android.gm.widget.GmailWidgetProvider") + if (id ~= nil) then + prefs.wid = id + else + ui:show_text("Can't add widget") + return + end +end + +-- Utils + +function concat(tbl, indicesToConcatenate, delimiter) + local resultTable = {} + + if #indicesToConcatenate > 0 then + local concatenatedString = {} + for _, index in ipairs(indicesToConcatenate) do + table.insert(concatenatedString, tbl[index]) + end + table.insert(resultTable, table.concat(concatenatedString, delimiter)) + end + + for i = 1, #tbl do + if not contains(indicesToConcatenate, i) then + table.insert(resultTable, tbl[i]) + end + end + return resultTable +end diff --git a/samples/android-widget-sample2.lua b/samples/android-widget-sample2.lua new file mode 100644 index 0000000..3c34729 --- /dev/null +++ b/samples/android-widget-sample2.lua @@ -0,0 +1,56 @@ +-- name = "Android widgets sample (The Weather Channel)" +-- uses_app = "com.weather.Weather" + +local prefs = require "prefs" + +local curr_temp = "" +local w_bridge = nil + +function on_resume() + if not widgets:bound(prefs.wid) then + setup_app_widget() + end + + widgets:request_updates(prefs.wid) +end + +function on_app_widget_updated(bridge) + local tab = bridge:dump_table() + + current_temp = tab.relative_layout_1.relative_layout_2.text_1 + location = tab.relative_layout_1.relative_layout_2.text_2 + w_bridge = bridge + + if location ~= nil and current_temp ~= nil then + ui:show_text(location..": "..current_temp) + else + ui:show_text("Empty") + end +end + +function on_app_widget_updated_alt(bridge) + local strings = bridge:dump_strings().values + + location = strings[2] + current_temp = strings[1] + w_bridge = bridge + + if location ~= nil and current_temp ~= nil then + ui:show_text(location..": "..current_temp) + else + ui:show_text("Empty") + end +end + +function on_click(idx) + w_bridge:click(current_temp) +end + +function setup_app_widget() + local id = widgets:setup("com.weather.Weather/com.weather.Weather.widgets.WeatherWidgetProvider2x2") + if (id ~= nil) then + prefs.wid = id + else + ui:show_text("Can't add widget") + end +end diff --git a/samples/android-widget-sample3.lua b/samples/android-widget-sample3.lua new file mode 100644 index 0000000..63424e5 --- /dev/null +++ b/samples/android-widget-sample3.lua @@ -0,0 +1,46 @@ +-- name = "Android widgets sample (Google Tasks)" + +local prefs = require "prefs" +local fmt = require "fmt" + +local max_mails = 1 +local curr_tab = {} +local w_bridge = nil + +function on_resume() + if not widgets:bound(prefs.wid) then + setup_app_widget() + end + + widgets:request_updates(prefs.wid) +end + +function on_app_widget_updated(bridge) + local tab = bridge:dump_strings().values + + -- Bold list name + tab[1] = fmt.bold(tab[1]) + + -- Remove "A fresh start" + table.remove(tab, #tab-1) + + curr_tab = tab + w_bridge = bridge + + ui:show_lines(tab) +end + +function on_click(idx) + --w_bridge:click(curr_tab[idx]) + w_bridge:click("text_2") +end + +function setup_app_widget() + local id = widgets:setup("com.google.android.apps.tasks/com.google.android.apps.tasks.features.widgetlarge.ListWidgetProvider") + if (id ~= nil) then + prefs.wid = id + else + ui:show_text("Can't add widget") + return + end +end -- 2.43.0 From 83150d0654114aa3d60442d069c8dbcad1290b68 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 15 Mar 2024 08:13:09 +0400 Subject: [PATCH 074/204] Add CHANGELOG.md file --- CHANGELOG.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 44 ++++++++++--------------------------------- 2 files changed, 63 insertions(+), 34 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..253a10f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,53 @@ +### 4.9.4 + +* The `aio:actions()` function now also returns arguments format for each action +* Added function `system:format_date_localized()` + +### 4.9.2 + +* The `apps` module now has an `app()` function that returns selected app table +* You can use `%%fa:ICON_NAME%%` tag in the any text to show FontAwesome icon inside the text + +### 4.9.0 + +* The `apps` module now has an `apps()` function that returns a table with app details, including the app icon; +* The `phone:contacts()` function now returns an icon that can be used in the side menu; +* The `apps:request_icons()` and `phone:request_icons()` functions are deprecated. + +### 4.8.0 + +* Side menu scripts support; +* New modules: `tasks` and `notes`; +* The `ui:colors()` can be called as `aio:colors()`; +* The `apps` and `phone` modules now returns icons; +* The `apps` modules now returns also Android for Work and cloned apps; +* The `apps` module now allows you to sort apps by category; +* The `phone` and `calendar` modules now have functions for requesting access rights; +* Added `phone:open_contact() function; +* Added `aio:actions()` function that returns a table of AIO Launcher actions; +* Added `calendar:open_new_event()` function that shows the system calendar with the new event. +* Added `aio:settings()` and `aio:open_settings()` functions + +### Older versions + +* 4.0.0 - first version with scripts support; +* 4.1.0 - added `weather` and `cloud` modules; +* 4.1.3 - added `notify`, `files` and `utils` modules; +* 4.1.5 - extended `notify` module, added `folded_string` arg to `ui:show_lines`; +* 4.3.0 - search scripts support; +* 4.4.0 - markdown support; +* 4.4.1 - rich text editor support; +* 4.4.2 - added `fmt` and `html` utility modules; +* 4.4.4 - added `tasker` module; +* 4.4.6 - added `csv` module; +* 4.4.7 - added `intent` module; +* 4.5.0 - the `aio` module has been significantly expanded, also added `system:currency()` and `ui:show_list_dialog()`; +* 4.5.2 - added `anim` and `morph` packages, added `calendar:open_event()` function; +* 4.5.3 - removed get_ prefixes where they are not needed while maintaining backward compatibility; +* 4.5.5 - added `on_action` callback and `calendar:add_event` function; +* 4.5.6 - `aio:active_widgets()` now returns also widget `label`, added `checks` module; +* 4.5.7 - added "fold" and "unfold" actions to the `on_action` callback; +* 4.6.0 - added `system:request_location()` and `tasker:send_command()` functions; +* 4.7.0 - added `ui:build()` and functions to display search results in different formats; +* 4.7.1 - fontawesome updated to version 6.3.0; +* 4.7.4 - added `prefs` module, `settings` module is deprecated. diff --git a/README.md b/README.md index 27a7c6a..6d6989d 100644 --- a/README.md +++ b/README.md @@ -18,40 +18,16 @@ The type of script is determined by the line (meta tag) at the beginning of the # Changelog +### 5.2.0 + +* Added `widgets` module to app widgets interaction + ### 5.1.0 * Added `add_purchase` action * Added `on_contacts_loaded()` callback -### 4.9.4 - -* The `aio:actions()` function now also returns arguments format for each action -* Added function `system:format_date_localized()` - -### 4.9.2 - -* The `apps` module now has an `app()` function that returns selected app table -* You can use `%%fa:ICON_NAME%%` tag in the any text to show FontAwesome icon inside the text - -### 4.9.0 - -* The `apps` module now has an `apps()` function that returns a table with app details, including the app icon; -* The `phone:contacts()` function now returns an icon that can be used in the side menu; -* The `apps:request_icons()` and `phone:request_icons()` functions are deprecated. - -### 4.8.0 - -* Side menu scripts support; -* New modules: `tasks` and `notes`; -* The `ui:colors()` can be called as `aio:colors()`; -* The `apps` and `phone` modules now returns icons; -* The `apps` modules now returns also Android for Work and cloned apps; -* The `apps` module now allows you to sort apps by category; -* The `phone` and `calendar` modules now have functions for requesting access rights; -* Added `phone:open_contact() function; -* Added `aio:actions()` function that returns a table of AIO Launcher actions; -* Added `calendar:open_new_event()` function that shows the system calendar with the new event. -* Added `aio:settings()` and `aio:open_settings()` functions +[Full changelog](CHANGELOG.md) # Widget scripts @@ -614,11 +590,11 @@ Starting from version 5.2.0, AIO Launcher supports interaction with app widgets _Deprecated in 4.7.4. Use Preferences module._ -~~* `settings:get()` - returns the settings table in an array of words format; -* `settings:set(table)` - saves the settings table in an array of words format; -* `settings:get_kv()` - returns the settings table in `key=value` format; -* `settings:set_kv(table)` - saves settings table in the format `key=value`; -* `settings:show_dialog()` - show settings change dialog.~~ +* ~~`settings:get()` - returns the settings table in an array of words format;~~ +* ~~`settings:set(table)` - saves the settings table in an array of words format;~~ +* ~~`settings:get_kv()` - returns the settings table in `key=value` format;~~ +* ~~`settings:set_kv(table)` - saves settings table in the format `key=value`;~~ +* ~~`settings:show_dialog()` - show settings change dialog.~~ ~~User can change settings through the dialog, which is available by clicking on the "gear" in the edit menu of the widget. If in the widget metadata there is a field `arguments_help`, its value will be shown in the edit dialog. If there is a field `arguments_default` - it will be used to get default arguments.~~ -- 2.43.0 From d8d9c12e07e74ba81fa8d6746c862bffa5ff16a4 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 19 Mar 2024 14:50:28 +0400 Subject: [PATCH 075/204] Update app widgets samples and community scripts --- .../google-tasks-app-widget.lua | 31 +++++++++-- community/todoist-app-widget.lua | 52 +++++++++++-------- 2 files changed, 56 insertions(+), 27 deletions(-) rename samples/android-widget-sample3.lua => community/google-tasks-app-widget.lua (51%) diff --git a/samples/android-widget-sample3.lua b/community/google-tasks-app-widget.lua similarity index 51% rename from samples/android-widget-sample3.lua rename to community/google-tasks-app-widget.lua index 63424e5..d8b536f 100644 --- a/samples/android-widget-sample3.lua +++ b/community/google-tasks-app-widget.lua @@ -1,4 +1,9 @@ --- name = "Android widgets sample (Google Tasks)" +-- name = "Google Tasks" +-- description = "AIO wrapper for the official Google Tasks app widget" +-- type = "widget" +-- author = "Evgeny Zobnin (zobnin@gmail.com)" +-- aio_version = "4.1.99" +-- uses_app = "com.google.android.apps.tasks" local prefs = require "prefs" local fmt = require "fmt" @@ -24,15 +29,17 @@ function on_app_widget_updated(bridge) -- Remove "A fresh start" table.remove(tab, #tab-1) - curr_tab = tab + curr_tab = deep_copy(tab) w_bridge = bridge + -- Change "Anything to add?" string to "Add task" + tab[#tab] = fmt.secondary("Add task") + ui:show_lines(tab) end function on_click(idx) - --w_bridge:click(curr_tab[idx]) - w_bridge:click("text_2") + w_bridge:click(curr_tab[idx]) end function setup_app_widget() @@ -44,3 +51,19 @@ function setup_app_widget() return end end + +function deep_copy(orig) + local orig_type = type(orig) + local copy + if orig_type == 'table' then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[deep_copy(orig_key)] = deep_copy(orig_value) + end + setmetatable(copy, deep_copy(getmetatable(orig))) + else + copy = orig + end + return copy +end + diff --git a/community/todoist-app-widget.lua b/community/todoist-app-widget.lua index 9675c20..2179aca 100644 --- a/community/todoist-app-widget.lua +++ b/community/todoist-app-widget.lua @@ -8,6 +8,8 @@ local prefs = require "prefs" local fmt = require "fmt" +local widget = "com.todoist/com.todoist.appwidget.provider.ItemListAppWidgetProvider" + local curr_tab = {} local w_bridge = nil local colors = {} @@ -22,30 +24,23 @@ end function on_app_widget_updated(bridge) w_bridge = bridge colors = bridge:dump_colors() - curr_tab = parse(bridge:dump_table()) + curr_tab = bridge:dump_table() + curr_tab = parse(curr_tab) ui:show_lines(curr_tab.lines) end function parse(t) local tab = {} - tab["list"] = t.v_layout_1.frame_layout_1.relative_layout_1.text_1 - local footer = t.v_layout_1.frame_layout_2 - for k,v in pairs(footer) do - if k:sub(1,8) == "relative" then - footer = v - break - end - end local images = {} - local texts = {} local lines = {} + local clicks = {} local tasks = t.v_layout_1.frame_layout_2.list_layout_1 - if tasks == nil then tasks = {} end + if not tasks then tasks = {} end local tkeys = {} for k,v in pairs(tasks) do table.insert(tkeys,k) end - table.sort(tkeys) + table.sort(tkeys,function (a,b) return tonumber(a:match("%d+")) < tonumber(b:match("%d+")) end) for i1,v1 in ipairs(tkeys) do for k2,v2 in pairs(tasks[v1]) do for k3,v3 in pairs(v2) do @@ -56,14 +51,14 @@ function parse(t) local subtexts = {} for k4,v4 in pairs(v3) do if k4:sub(1,4) == "text" then - table.insert(texts,v4) + table.insert(clicks,k4) text = v4 - local color = colors[images[#texts]] + local color = colors[images[#images]] if color ~= "#909090" and color then text = fmt.colored(fmt.bold(text),color) end elseif k4:sub(1,8) == "h_layout" then - subtexts = recursion(v4,subtexts,#subtexts,false) + subtexts = recursion(v4,subtexts,1,false) end end table.insert(lines,text..table.concat(subtexts)) @@ -71,19 +66,30 @@ function parse(t) end end end + local footer = t.v_layout_1.frame_layout_2 + for k,v in pairs(footer) do + if k:sub(1,8) == "relative" then + footer = v + break + end + end for k1,v1 in pairs(footer) do for k2,v2 in pairs(v1) do if k2:sub(1,4) == "text" then table.insert(images,k2) - table.insert(texts,v2) - table.insert(lines,fmt.secondary("Add task")) + table.insert(clicks,k2) + local add_task = "Add task" + if #lines ~= 0 then + add_task = fmt.secondary(add_task) + end + table.insert(lines,add_task) break end end end tab["images"] = images - tab["texts"] = texts tab["lines"] = lines + tab["clicks"] = clicks return tab end @@ -95,25 +101,25 @@ function recursion(t,tab,idx,flag) table.insert(tab,idx,fmt.secondary(" - ") .. fmt.colored(v,colors[k])) end elseif k:sub(1,8) == "h_layout" then - tab = recursion(v,tab,1,true) + tab = recursion(v,tab,#tab+1,true) end end return tab end function on_click(idx) - w_bridge:click(curr_tab.texts[idx]) + w_bridge:click(curr_tab.clicks[idx]) end function setup_app_widget() - local id = widgets:setup("com.todoist/com.todoist.appwidget.provider.ItemListAppWidgetProvider") + local id = widgets:setup(widget) if (id ~= nil) then prefs.wid = id else - ui:show_text("Can't add widget") + ui:show_toast("Can't add widget") end end function on_settings() - w_bridge:click(curr_tab.list) + w_bridge:click("text_1") end -- 2.43.0 From 91993ae4a67ef5a8c7c4b7758ea08a3e2279309d Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 22 Mar 2024 22:02:45 +0400 Subject: [PATCH 076/204] Add new scripts from Theodor Galanis --- community/amdroid-nextalarm-app-widget.lua | 48 ++++++++++++++++++++++ community/google-search-app-widget.lua | 41 ++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 community/amdroid-nextalarm-app-widget.lua create mode 100644 community/google-search-app-widget.lua diff --git a/community/amdroid-nextalarm-app-widget.lua b/community/amdroid-nextalarm-app-widget.lua new file mode 100644 index 0000000..2f067ce --- /dev/null +++ b/community/amdroid-nextalarm-app-widget.lua @@ -0,0 +1,48 @@ +-- name = "Amdroid Next Alarm" +-- description = "AIO wrapper for the Amdroid next alarm app widget" +-- type = "widget" +-- author = "Theodor Galanis" +-- version = "1.0" +-- foldable = "false" +-- uses_app = "com.amdroidalarmclock.amdroid" + +local prefs = require "prefs" + +local next_alarm = "" +local w_bridge = nil + +function on_resume() + if not widgets:bound(prefs.wid) then + setup_app_widget() + end + + widgets:request_updates(prefs.wid) +end + +function on_app_widget_updated(bridge) + local tab = bridge:dump_table() + + next_alarm = tab.v_layout_1.text_1 + w_bridge = bridge + + if next_alarm ~= nil + then + ui:show_table({{" ", "%%fa:alarm-clock%% "..next_alarm, " "}}, 0, true) + else + ui:show_text("Empty") + end +end + +function on_click(idx) + w_bridge:click(next_alarm) +end + +function setup_app_widget() + local id = widgets:setup("com.amdroidalarmclock.amdroid/com.amdroidalarmclock.amdroid.widgets.NextAlarmWidgetProvider") + + if (id ~= nil) then + prefs.wid = id + else + ui:show_text("Can't add widget") + end +end diff --git a/community/google-search-app-widget.lua b/community/google-search-app-widget.lua new file mode 100644 index 0000000..9190cdd --- /dev/null +++ b/community/google-search-app-widget.lua @@ -0,0 +1,41 @@ +-- name = "Google search" +-- description = "AIO wrapper for the Google search app widget" +-- type = "widget" +-- author = "Theodor Galanis" +-- version = "1.0" +-- foldable = "false" +-- uses_app: "com.google.android.googlequicksearchbox"" + +local prefs = require "prefs" + +local buttons_labels = {"GOOGLE", "fa:magnifying-glass", "fa:microphone", "fa:camera"} +local buttons_targets = {"image_3", "image_2", "image_5", "image_6"} +local w_bridge = nil + +function on_resume() + if not widgets:bound(prefs.wid) then + setup_app_widget() + end + + widgets:request_updates(prefs.wid) +end + +function on_app_widget_updated(bridge) + w_bridge = bridge + ui:show_buttons(buttons_labels) +end + +function on_click(idx) + w_bridge:click(buttons_targets[idx]) +end + +function setup_app_widget() + local id = widgets:setup("com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.SearchWidgetProvider") + + if (id ~= nil) then + prefs.wid = id + else + ui:show_text("Can't add widget") + return + end +end -- 2.43.0 From e563c5cbebe84a58db5ff5538a5a6f24baf1fc7c Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 24 Mar 2024 19:39:54 +0400 Subject: [PATCH 077/204] move classic todoist widget to defunct folder --- {community => defunct}/todoist-widget.lua | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {community => defunct}/todoist-widget.lua (100%) diff --git a/community/todoist-widget.lua b/defunct/todoist-widget.lua similarity index 100% rename from community/todoist-widget.lua rename to defunct/todoist-widget.lua -- 2.43.0 From db7149229a04fbf437109473cb387bc9fda92a47 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 30 Mar 2024 17:57:49 +0400 Subject: [PATCH 078/204] Add complex UI docs and samples --- README.md | 13 ++++- README_RICH_UI.md | 81 +++++++++++++++++++++++++++++++ samples/rich-gui-basic-sample.lua | 16 ++++++ samples/rich-gui-sample.lua | 67 +++++++++++++++++++++++++ 4 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 README_RICH_UI.md create mode 100644 samples/rich-gui-basic-sample.lua create mode 100644 samples/rich-gui-sample.lua diff --git a/README.md b/README.md index 6d6989d..6f58d3b 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,10 @@ The type of script is determined by the line (meta tag) at the beginning of the # Changelog +### 5.2.1 + +* Added support for complex UIs + ### 5.2.0 * Added `widgets` module to app widgets interaction @@ -349,8 +353,7 @@ end ## Application management * `apps:apps([sort_by])` - returns the table of tables of all installed applications; -* `apps:app(package_name)` - return the table of tables of the given application; -, `sort_by` - sort option (see below); +* `apps:app(package_name)` - return the table of the given application; * `apps:launch(package)` - launches the application; * `apps:show_edit_dialog(package)` - shows edit dialog of the application; * `apps:categories()` - returns a table of category tables. @@ -580,6 +583,12 @@ _Avaialble from: 4.1.3_ All files are created in the subdirectory `/sdcard/Android/data/ru.execbit.aiolauncher/files/scripts` without ability to create subdirectories. +## Rich UI + +Starting with version 5.2.1, AIO Launcher includes an API that allows for displaying a more complex interface than what the high-level functions of the `ui` module allowed. For example, you can display text of any size, center it, move it up and down, display buttons on the left and right sides of the screen, draw icons of different sizes, and much more. Essentially, you can replicate the appearance of any built-in AIO widget. + +[Detailed instructions](README_RICH_UI.md) + ## App widgets Starting from version 5.2.0, AIO Launcher supports interaction with app widgets through scripts. This means that you can create a wrapper for any app's widget that will fully match the appearance and style of AIO. You can also use this API if you need to retrieve information from other applications, such as the balance on your mobile phone account or your car's parking spot. If the application has a widget providing such information, you will be able to access it. diff --git a/README_RICH_UI.md b/README_RICH_UI.md new file mode 100644 index 0000000..e144ae8 --- /dev/null +++ b/README_RICH_UI.md @@ -0,0 +1,81 @@ +Starting with version 5.2.1, AIO Launcher includes an API that allows for displaying a more complex interface than what the high-level functions of the `ui` module allowed. For example, you can display text of any size, center it, move it up and down, display buttons on the left and right sides of the screen, draw icons of different sizes, and much more. Essentially, you can replicate the appearance of any built-in AIO widget. + +Open the example [samples/rich-gui-basic-sample.lua] and study it. As you can see, the new API consists of just one function `gui`, which takes a table describing the UI as input and returns an object that has a `render()` method for drawing this UI. + +The UI is built line by line, using commands that add elements from left to right, with the possibility of moving to a new line. The provided example displays two lines, under which are two buttons: + +``` +{"text", "First line"}, +{"new_line", 1}, +{"text", "Second line"}, +{"new_line", 2}, +{"button", "Button #1"}, +{"spacer", 2}, +{"button", "Button #2"}, +``` + +The first command displays the line "First line", the "new_line" command moves to a new line, adding a space equal to one unit (each unit is 4 pixels). Then, the "text" command adds a new line, followed by a move to a new line and the display of two buttons. Since there is no "new_line" command between the button display commands, they will be displayed in one line, one after the other, from left to right with a gap of 2 units. The "spacer" command is responsible for the horizontal gap. + +This example is already useful, but it's too plain. Let's add some colors and vary the text lines a bit: make the first line larger, and write the second line in italic font. Also, let's work on the color of the buttons: + +``` +{"text", "First line", {size = 21}}, +{"new_line", 1}, +{"text", "Second line"}, +{"new_line", 2}, +{"button", "Button #1", {color = "#ff0000"}}, +{"spacer", 2}, +{"button", "Button #2", {color = "#0000ff"}}, +``` + +To change the size of a line, we used the table `{size = 21}`. This is the standard approach if a command has more than one parameter, then all other arguments are passed in the table. To make the text italic, we used the HTML tag ``. The "text" command supports many tags for text transformation. The color of the buttons is also changed using a table. + +It's more interesting now, but again, an interface where all elements are grouped on the left side may not always be suitable. We need a way to align elements on the right side of the screen or in the center. Let's make the first line be in the middle of the line (kind of like a title), and the second button - on the right side: + +``` +{"text", "First line", {size = 21, gravity = "center_h"}}, +{"new_line", 1}, +{"text", "Second line"}, +{"new_line", 2}, +{"button", "Button #1", {color = "#ff0000"}}, +{"spacer", 2}, +{"button", "Button #2", {color = "#0000ff", gravity = "right"}}, +``` + +Here we used the `gravity` parameter to change the location of the element in the line. Three things are important to know about `gravity`: + +1. It changes the position of the element only within the current line; +2. Possible `gravity` values: `left`, `top`, `right`, `bottom`, `center_h` (horizontal centering), `center_v` (vertical centering); +3. `Gravity` values can be combined, for example, to display a text element in the top right corner of the current line, you can specify `gravity = "top|right"`; + +Also, there are two limitations to know about: + +1. The `center_h` value is applied to each element separately, meaning if you add two lines with the gravity value `center_h` in one line, they will not both be grouped and displayed in the center, but instead, they will split the screen in half and be displayed each in the center of its half; +2. The `right` value affects not only the element to which it is applied but also all subsequent elements in the current line. That means if you add another button after "Button #2", it will also be on the right side after "Button #2". + +Surely you will want to add icons to your UI. There are several ways to do this. The first way is to embed the icon directly into the text, in this case, you can use any icon from the FontAwesome set: + +``` +{"text", "This is icon: %%fa:microphone%%"} +``` + +The second way: use the icon command (in this case, you can also specify the size and color of the icon): + +``` +{"icon", "fa:microphone", {size = 32, color = "#ff0000"}} +``` + +The second method also allows displaying icons of applications and contacts. How to do this is shown in the example [samples/rich-ui-sample.lua]. + +Handling clicks on elements works the same as when using the `ui` module API. Just define `on_click()` or `on_long_click()` functions. The first parameter of the function will be the index of the element. How to use this mechanism can be learned in the example [samples/rich-ui-sample.lua]. + +This is all you need to know about the new API. Below is an example demonstrating all supported elements and all their default parameters: + +``` +{"text", "", {size = 17, gravity = "left"}}, +{"button", "", {color = "", gravity = "left"}}, +{"icon", "", {size = 17, color = "", gravity = "left"}}, +{"progress" "", {progress = 0, color = "", gravity = "left"}}, +{"new_line", 0}, +{"spacer", 0}, +``` diff --git a/samples/rich-gui-basic-sample.lua b/samples/rich-gui-basic-sample.lua new file mode 100644 index 0000000..05dcb6d --- /dev/null +++ b/samples/rich-gui-basic-sample.lua @@ -0,0 +1,16 @@ +-- name = "Rich GUI Basic sample" + +function on_resume() + my_gui = gui{ + {"text", "First line"}, + {"new_line", 1}, + {"text", "Second line"}, + {"new_line", 2}, + {"button", "Button #1"}, + {"spacer", 2}, + {"button", "Button #2"}, + } + + my_gui.render() +end + diff --git a/samples/rich-gui-sample.lua b/samples/rich-gui-sample.lua new file mode 100644 index 0000000..e7ee715 --- /dev/null +++ b/samples/rich-gui-sample.lua @@ -0,0 +1,67 @@ +-- name = "Rich GUI sample" + +function on_resume() + local app = apps:app("ru.execbit.aiolauncher") + if app == nil then return end + + my_gui = gui{ + {"text", "Title", {size = 19, gravity = "center_h"}}, + {"new_line", 2}, + {"text", "Hello, World", {size = 21}}, + {"spacer", 2}, + {"text", "Center small text", {size = 8, gravity = "center_v"}}, + {"text", "Top right text", {size = 8, gravity = "top|right"}}, + {"new_line", 1}, + {"button", "Ok", {color = "#00aa00"}}, + {"button", "Neutral", {color = "#666666", gravity = "right"}}, + {"spacer", 2}, + {"button", "Cancel", {color = "#ff0000", gravity = "right"}}, + {"new_line", 2}, + {"progress", "Progress #1", {progress = 70}}, + {"progress", "Progress #2", {progress = 30, color = "#0000ff"}}, + {"new_line", 2}, + {"button", "Center button", {gravity = "center_h"}}, + {"new_line", 2}, + {"icon", "fa:microphone", {size = 17, color = "#00ff00", gravity = "center_v"}}, + {"spacer", 4}, + {"icon", "fa:microphone", {size = 22, gravity = "center_v"}}, + {"spacer", 4}, + {"icon", "fa:microphone", {size = 27, gravity = "center_v"}}, + {"spacer", 4}, + {"icon", "fa:microphone", {size = 32, gravity = "center_v"}}, + {"icon", app.icon, {size = 17, gravity = "center_v|right"}}, + {"spacer", 4}, + {"icon", app.icon, {size = 22, gravity = "center_v"}}, + {"spacer", 4}, + {"icon", app.icon, {size = 27, gravity = "center_v"}}, + {"spacer", 4}, + {"icon", app.icon, {size = 32, gravity = "center_v"}}, + } + + my_gui.render() +end + +function on_apps_changed() + on_resume() +end + +function on_click(idx, extra) + local elem_name = my_gui.ui[idx][1] + + if elem_name == "text" then + my_gui.ui[idx][2] = ""..my_gui.ui[idx][2].."" + elseif elem_name == "button" then + my_gui.ui[idx][2] = "Clicked" + elseif elem_name == "progress" then + my_gui.ui[idx][3].progress = 100 + elseif elem_name == "icon" then + my_gui.ui[idx][3].color = "#ff0000" + end + + my_gui.render() + ui:show_toast("Clicked: "..my_gui.ui[idx][1]) +end + +function on_long_click(idx) + ui:show_toast("Long click: "..my_gui.ui[idx][1]) +end -- 2.43.0 From 897fee33b79641ee9670caf0da0ef2587a81768d Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 31 Mar 2024 08:15:15 +0400 Subject: [PATCH 079/204] Add complex UI docs and samples #2: add color to the text --- README_RICH_UI.md | 2 +- samples/rich-gui-sample.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README_RICH_UI.md b/README_RICH_UI.md index e144ae8..5a43e8b 100644 --- a/README_RICH_UI.md +++ b/README_RICH_UI.md @@ -72,7 +72,7 @@ Handling clicks on elements works the same as when using the `ui` module API. Ju This is all you need to know about the new API. Below is an example demonstrating all supported elements and all their default parameters: ``` -{"text", "", {size = 17, gravity = "left"}}, +{"text", "", {size = 17, color = "", gravity = "left"}}, {"button", "", {color = "", gravity = "left"}}, {"icon", "", {size = 17, color = "", gravity = "left"}}, {"progress" "", {progress = 0, color = "", gravity = "left"}}, diff --git a/samples/rich-gui-sample.lua b/samples/rich-gui-sample.lua index e7ee715..b045508 100644 --- a/samples/rich-gui-sample.lua +++ b/samples/rich-gui-sample.lua @@ -5,7 +5,7 @@ function on_resume() if app == nil then return end my_gui = gui{ - {"text", "Title", {size = 19, gravity = "center_h"}}, + {"text", "Title", {size = 19, color = "#ff0000", gravity = "center_h"}}, {"new_line", 2}, {"text", "Hello, World", {size = 21}}, {"spacer", 2}, -- 2.43.0 From 3917c09837110c9ccd6a760f007473b3ea084150 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 1 Apr 2024 08:53:59 +0400 Subject: [PATCH 080/204] Update google search widget --- community/google-search-app-widget.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/community/google-search-app-widget.lua b/community/google-search-app-widget.lua index 9190cdd..6804f6d 100644 --- a/community/google-search-app-widget.lua +++ b/community/google-search-app-widget.lua @@ -2,14 +2,15 @@ -- description = "AIO wrapper for the Google search app widget" -- type = "widget" -- author = "Theodor Galanis" --- version = "1.0" +-- version = "1.01" -- foldable = "false" -- uses_app: "com.google.android.googlequicksearchbox"" local prefs = require "prefs" +prefs._name = "google" -local buttons_labels = {"GOOGLE", "fa:magnifying-glass", "fa:microphone", "fa:camera"} -local buttons_targets = {"image_3", "image_2", "image_5", "image_6"} +local buttons_labels = {" G ", "fa:magnifying-glass", "fa:microphone", "fa:camera"} +local buttons_targets = {"image_7", "image_4", "image_9", "image_10"} local w_bridge = nil function on_resume() @@ -31,8 +32,8 @@ end function setup_app_widget() local id = widgets:setup("com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.SearchWidgetProvider") - - if (id ~= nil) then + + if (id ~= nil) then prefs.wid = id else ui:show_text("Can't add widget") -- 2.43.0 From 3182eb011242e424ce90f50eb586db8d701dd7d7 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 8 Apr 2024 15:25:04 +0400 Subject: [PATCH 081/204] Add clarification about on_settings callback --- README.md | 8 ++++++++ samples/search-settings-test.lua | 19 ------------------- 2 files changed, 8 insertions(+), 19 deletions(-) delete mode 100644 samples/search-settings-test.lua diff --git a/README.md b/README.md index 6f58d3b..cc9399f 100644 --- a/README.md +++ b/README.md @@ -350,6 +350,14 @@ function on_action() end ``` +To change the action of the settings icon in the widget's edit menu, you can add the on_settings() function to the script. It will be called every time the user presses the icon. + +``` +function on_action() + ui:show_toast("Settings icon clicked!") +end +``` + ## Application management * `apps:apps([sort_by])` - returns the table of tables of all installed applications; diff --git a/samples/search-settings-test.lua b/samples/search-settings-test.lua deleted file mode 100644 index d3a8d8b..0000000 --- a/samples/search-settings-test.lua +++ /dev/null @@ -1,19 +0,0 @@ --- type = "search" - -settings_init = false - -function on_search() - if not settings_init then - search:show_buttons{ "Set settings" } - else - search:show_buttons{ "Result #1", "Result #2" } - end -end - -function on_click(idx) - if not settings_init then - settings:show_dialog() - else - -- main work - end -end -- 2.43.0 From d2c81220dcf9aeaefb0537bede8954904a7df2e4 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 9 Apr 2024 10:39:54 +0400 Subject: [PATCH 082/204] Update Widget Switcher script --- main/widgets-on-off.lua | 233 ++++++++++++++++++++++------------------ 1 file changed, 127 insertions(+), 106 deletions(-) diff --git a/main/widgets-on-off.lua b/main/widgets-on-off.lua index f554cba..afa27d9 100644 --- a/main/widgets-on-off.lua +++ b/main/widgets-on-off.lua @@ -1,40 +1,109 @@ --- name = "Widgets switcher" +-- name = "Переключатель виджетов" -- description = "Turns screen widgets on and off when buttons are pressed" -- type = "widget" --- arguments_help = "Don't change the arguments directly, use the long click menu." -- author = "Andrey Gavrilov" --- version = "2.0" +-- version = "2.1" ---constants-- - -local widgets = {"weather","weatheronly","clock","alarm","worldclock","monitor","traffic","player","apps","appbox","applist","appfolders","contacts","notify","dialogs","dialer","timer","stopwatch","mail","notes","tasks", "health", "feed","telegram","calendar","calendarw","exchange","finance","bitcoin","control","recorder","calculator","empty"} - -local icons = {"fa:user-clock","fa:sun-cloud","fa:clock","fa:alarm-clock","fa:business-time","fa:network-wired","fa:exchange","fa:play-circle","fa:robot","fa:th","fa:list","fa:folder","fa:address-card","fa:bell","fa:comment-alt-minus","fa:phone-alt","fa:chess-clock","fa:stopwatch","fa:at","fa:sticky-note","fa:calendar-check", "fa:heart-pulse", "fa:rss-square","fa:paper-plane","fa:calendar-alt","fa:calendar-week","fa:euro-sign","fa:chart-line","fa:coins","fa:wifi","fa:microphone-alt","fa:calculator-alt","fa:eraser"} - -local names = {"Clock & weather","Weather","Clock","Alarm","World clock","Monitor","Traffic","Player","Frequent apps","My apps","App list","App folders","Contacts","Notify","Dialogs","Dialer","Timer","Stopwatch","Mail","Notes","Tasks", "Health", "Feed","Telegram","Calendar","Weekly calendar","Exchange","Finance","Bitcoin","Control panel","Recorder","Calculator","Empty widget"} - ---variables-- +prefs = require "prefs" +prefs._name = "widgets" local pos = 0 +local color = aio:colors() +local enabled_color = "#1976d2" +local disabled_color = aio:colors().button +local buttons,colors = {},{} -function on_resume() - if next(settings:get()) == nil then - set_default_args() - end - ui:set_folding_flag(true) - local buttons,colors = get_buttons() - ui:show_buttons(buttons, colors) -end - -function on_click(idx) - pos = idx - redraw() +function on_alarm() + widgets = get_widgets() + if not prefs.widgets then + prefs.widgets = widgets.name + end + indexes = get_indexes(prefs.widgets, widgets.name) + ui:show_buttons(get_buttons()) end function on_long_click(idx) - pos = idx - local tab = settings:get() - ui:show_context_menu({{"angle-left",""},{"ban",""},{"angle-right",""},{icons[get_checkbox_idx()[idx]]:gsub("fa:",""),names[get_checkbox_idx()[idx]]}}) + system:vibrate(10) + pos = idx + if idx > #prefs.widgets then + return + end + ui:show_context_menu({{"angle-left",""},{"ban",""},{"angle-right",""},{widgets.icon[indexes[idx]],widgets.label[indexes[idx]]}}) +end + +function on_click(idx) + system:vibrate(10) + if idx > #prefs.widgets then + on_settings() + return + end + local widget = prefs.widgets[idx] + if not aio:is_widget_added(widget) then + aio:add_widget(widget, get_pos()) + aio:fold_widget(widget, false) + else + aio:remove_widget(widget) + end + on_alarm() +end + +function on_dialog_action(data) + if data == -1 then + return + end + local tab = {} + for i,v in ipairs(data) do + tab[i] = widgets.name[v] + end + prefs.widgets = tab + on_alarm() +end + +function on_settings() + ui:show_checkbox_dialog("Select widgets", widgets.label, indexes) +end + +function get_indexes(tab1,tab2) + local tab = {} + for i1,v1 in ipairs(tab1) do + for i2,v2 in ipairs(tab2) do + if v1 == v2 then + tab[i1] = i2 + break + end + end + end + return tab +end + +function get_buttons() + buttons,colors = {},{} + for i,v in ipairs(indexes) do + table.insert(buttons, "fa:" .. widgets.icon[v]) + table.insert(colors, widgets.enabled[v] and enabled_color or disabled_color) + end + --table.insert(buttons, "fa:gear") + --table.insert(colors, color.disabled_icon) + return buttons,colors +end + +function move(x) + local tab = prefs.widgets + if (pos*x == -1) or (pos*x == #tab) then + return + end + local cur = tab[pos] + tab[pos] = tab[pos+x] + tab[pos+x] = cur + prefs.widgets = tab + on_alarm() +end + +function remove() + local tab = prefs.widgets + table.remove(tab,pos) + prefs.widgets = tab + on_alarm() end function on_context_menu_click(menu_idx) @@ -44,90 +113,42 @@ function on_context_menu_click(menu_idx) remove() elseif menu_idx == 3 then move(1) - elseif menu_idx == 4 then - redraw() end end -function on_dialog_action(data) - if data == -1 then - return - end - settings:set(data) - on_resume() +function on_widget_action(action, name) + on_alarm() end -function on_settings() - ui:show_checkbox_dialog("Select widgets", names, get_checkbox_idx()) +function get_pos() + local name = aio:self_name() + local tab = aio:active_widgets() + for _,v in ipairs(tab) do + if v.name == name then + return v.position+1 + end + end + return 4 end ---utilities-- - -function redraw() - local buttons,colors = get_buttons() - local checkbox_idx = get_checkbox_idx() - local widget = widgets[checkbox_idx[pos]] - if aio:is_widget_added(widget) then - aio:remove_widget(widget) - colors[pos] = "#909090" - else - aio:add_widget(widget) - colors[pos] = "#1976d2" - end - ui:show_buttons(buttons, colors) -end - -function set_default_args() - local args = {} - for i = 1, #widgets do - table.insert(args, i) - end - settings:set(args) -end - -function get_checkbox_idx() - local tab = settings:get() - for i = 1, #tab do - tab[i] = tonumber(tab[i]) - end - return tab -end - -function get_buttons() - local buttons,colors = {},{} - local checkbox_idx = get_checkbox_idx() - for i = 1, #checkbox_idx do - table.insert(buttons, icons[checkbox_idx[i]]) - local widget = widgets[checkbox_idx[i]] - if widget ~= nil then - if aio:is_widget_added(widget) then - table.insert(colors, "#1976d2") - else - table.insert(colors, "#909090") - end - end - end - return buttons,colors -end - -function move(x) - local tab = settings:get() - if (pos == 1 and x < 0) or (pos == #tab and x > 0) then - return - end - local cur = tab[pos] - local prev = tab[pos+x] - tab[pos+x] = cur - tab[pos] = prev - settings:set(tab) - local buttons,colors = get_buttons() - ui:show_buttons(buttons, colors) -end - -function remove() - local tab = settings:get() - table.remove(tab,pos) - settings:set(tab) - local buttons,colors = get_buttons() - ui:show_buttons(buttons, colors) +function get_widgets() + local tab = {} + tab.icon = {} + tab.name = {} + tab.label = {} + tab.enabled = {} + for i,v in ipairs(aio:available_widgets()) do + if v.type == "builtin" then + table.insert(tab.icon, v.icon) + table.insert(tab.name, v.name) + table.insert(tab.label, v.label) + table.insert(tab.enabled, v.enabled) + end + end + local cal_widget = "my-calendar.lua" + table.insert(tab.icon, "calendar-days") + table.insert(tab.name, cal_widget) + table.insert(tab.label, "Месячный календарь") + table.insert(tab.enabled, aio:is_widget_added(cal_widget)) + return tab end -- 2.43.0 From df9354937b9a7d1a9d49171ddb3a4afe608832de Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 9 Apr 2024 10:40:27 +0400 Subject: [PATCH 083/204] Update zip --- scripts.md5 | 2 +- scripts.zip | Bin 22405 -> 22198 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts.md5 b/scripts.md5 index 584ed34..1673e6c 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -b4e2cc2aa0836b343b71d1c5181a8dd3 +ddadeb63256e4e14a7f89bbe6a0c2c17 diff --git a/scripts.zip b/scripts.zip index 7291ce2173728bb0c62f7350cf02a7dfdc79fadf..1a75e4e8b7a6fd3b1545f2024f673783722a1131 100644 GIT binary patch delta 1752 zcmZ9MX;_k38^<4bK*=RDCHDoj#U*#m1=LDQ30DNoUKBCVRJ28>vKqh)(>I&Ohpa4I z7}3-$m&$S(vDeAev9!@@OvkOX9M^QhEgKX*z2{u#-2dyo@Bg{(^W}Hx0qk)F?3yz| zy-1Bwg%iOxL=6n?zX{xZx9t(c@JNYz;@0k~NZoDmw`8o9p|0RVo=kg1&>OJziz zv3`=zC;~9VClCNOE`G?s)lqx(U;Xl)ed#xe*JdifZGwJ&G6EaAUuIN$A}p@I$i%O> zH>QZ5_=JkIVz-!IAzQ!?bl4Row#-GS)qb`VX#2+J&#W%5nn0V(UgQY0o(&`p)Q^@= zQ^cpm=U0~&qr^$)m09)UqdGl}Q)`ny&a45Vzo+x3cYocf#_LWYRq?5G%%4qhWr738 zJ&$pw4?ivz9Plvm;$>|5`x>d+GNm*ms1j<1C?z3E|HQ_PMWw5q*# zc6+FmnuuYF%vqj&AYnACK6LZ(BBn%^mo@fFO_ z86SoEo|eptJvp)8jv7WM&}`(5xBd4;w$tID>DT%O2X$F%mme6+`ElWCJ;5mQy^oK| zja#Gn2_QHqe0bu9|G{zR~VeX(!dK_k@lb++gph2&ur*bv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ckF^dpfUgi5p+4^X-?n1599;c2OfeTXNP-=RIb?f=so^3n!o__E PpE=n7f`LFp`@`sejD}-3 -- 2.43.0 From dec11bf971ea0c9da1d727df017da9065e17c546 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 9 Apr 2024 10:47:57 +0400 Subject: [PATCH 084/204] Update Widget Switcher script --- main/widgets-on-off.lua | 4 ++-- scripts.md5 | 2 +- scripts.zip | Bin 22198 -> 22197 bytes 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main/widgets-on-off.lua b/main/widgets-on-off.lua index afa27d9..2d69992 100644 --- a/main/widgets-on-off.lua +++ b/main/widgets-on-off.lua @@ -9,8 +9,6 @@ prefs._name = "widgets" local pos = 0 local color = aio:colors() -local enabled_color = "#1976d2" -local disabled_color = aio:colors().button local buttons,colors = {},{} function on_alarm() @@ -77,6 +75,8 @@ function get_indexes(tab1,tab2) end function get_buttons() + local enabled_color = aio:colors().progress_good + local disabled_color = aio:colors().button buttons,colors = {},{} for i,v in ipairs(indexes) do table.insert(buttons, "fa:" .. widgets.icon[v]) diff --git a/scripts.md5 b/scripts.md5 index 1673e6c..385b187 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -ddadeb63256e4e14a7f89bbe6a0c2c17 +f479d227b90a6f98f309841cdcce9f38 diff --git a/scripts.zip b/scripts.zip index 1a75e4e8b7a6fd3b1545f2024f673783722a1131..6369f694eb3d4609f390ff18a98a629d09f399d5 100644 GIT binary patch delta 1348 zcmV-K1-tsTtpT;I0k9i06W3LVSj>t4S51!FHWXeusMy+DCpVGtxm(m{F#`9^*GvqW2-6g37TlJEC>d_Pi>pb~EhnxUZkv-@y- z-F@i(?w*dn9e?Q_e~)iq_jG)Vx_8~j?tS+cFudvh>D~o?lAxT_tBURf<)sw=v8l=$ z!4V-Px}*7;h#CP2mpS4^f$lbNzHEfxz=kV=b`_~>k}F-}uv0#0Idy~^vEh|G{I1L^ zazNkXwxW!;irSK@HioC^B=CLER@A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A1p7Wn%WK$H^!tW^bgT}rK95uDq%nUC7Mr51v3k}tpbJey)e&sgmOhB9L9w}F}#_R%zJ#x6U z1r2|@tvBU;YPN_E6!GT0n7HG@70G|(Cux@mK6~+NM35W`ep#) zd*CEI(O2kZ#81zwsDRw_J*mpG=B&y>(7i~vv}l5d2TY1JrxQ+dfg_9|;CM+2yVS&r ztv8lx{bV3#ZelS9BNmIuk~mpX?$RC~M;w3th_4^>-DJ3#bWKy!)fB z9br(IN)*aUZ6zS*Y;jg1^LAmxofi_oeeXkN5AW=hmK(adTb6s{Q-HsvoUVjbiTesu z=@r?kJQqJKQ7|Nl;NMgi&Y9ctNO_(_Z8Gp(aw*?!qfnq})J|Q{)B%~E1Ck)_0Cif8 z{i#4EGLme1L0ndp+&QN<1%_+;)E9rMVtpBaQ=9R zY@+4{eQ}EHC4B=2gO?SOsg;xz~+7%gB47g^df;{RcGp- zp?@}F_dxgg?0}VO0)wq_%x+b`9_&r+U!6V5=aw)oVZG|1fBLN$-ZhsE<1k9_$w{Xd zSlc3CF%4h@A_5n{Hgm3!I#Zb_YB`O@8M(S>Gm+? z$FaAif$F}|+VS)+P)h>@lYdkgvmrPP91WsWiCAaHVMD0|002&tI#etK58@PNli^Mq zlZ8|s0S1$#R9OS{IslUqI~$W5RX_nhlU!9>0lSm9Ra*i5lN4540ke~ERzC)rP5=M^ E08a6L%>V!Z -- 2.43.0 From 6d713a3cc00c8b81d820eb63c481ddd636d2a01d Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 9 Apr 2024 11:07:31 +0400 Subject: [PATCH 085/204] Update scripts zip --- main/widgets-on-off.lua | 230 ++++++++++++++++++---------------------- scripts.md5 | 2 +- scripts.zip | Bin 22197 -> 22429 bytes 3 files changed, 107 insertions(+), 125 deletions(-) diff --git a/main/widgets-on-off.lua b/main/widgets-on-off.lua index 2d69992..3fee690 100644 --- a/main/widgets-on-off.lua +++ b/main/widgets-on-off.lua @@ -1,109 +1,43 @@ --- name = "Переключатель виджетов" +-- name = "Widgets switcher" -- description = "Turns screen widgets on and off when buttons are pressed" -- type = "widget" +-- arguments_help = "Don't change the arguments directly, use the long click menu." -- author = "Andrey Gavrilov" -- version = "2.1" -prefs = require "prefs" -prefs._name = "widgets" +--constants-- + +local enabled_color = aio:colors().progress_good +local disabled_color = aio:colors().button + +local widgets = {"weather","weatheronly","clock","alarm","worldclock","monitor","traffic","player","apps","appbox","applist","appfolders","contacts","notify","dialogs","dialer","timer","stopwatch","mail","notes","tasks", "health", "feed","telegram","calendar","calendarw","exchange","finance","bitcoin","control","recorder","calculator","empty"} + +local icons = {"fa:user-clock","fa:sun-cloud","fa:clock","fa:alarm-clock","fa:business-time","fa:network-wired","fa:exchange","fa:play-circle","fa:robot","fa:th","fa:list","fa:folder","fa:address-card","fa:bell","fa:comment-alt-minus","fa:phone-alt","fa:chess-clock","fa:stopwatch","fa:at","fa:sticky-note","fa:calendar-check", "fa:heart-pulse", "fa:rss-square","fa:paper-plane","fa:calendar-alt","fa:calendar-week","fa:euro-sign","fa:chart-line","fa:coins","fa:wifi","fa:microphone-alt","fa:calculator-alt","fa:eraser"} + +local names = {"Clock & weather","Weather","Clock","Alarm","World clock","Monitor","Traffic","Player","Frequent apps","My apps","App list","App folders","Contacts","Notify","Dialogs","Dialer","Timer","Stopwatch","Mail","Notes","Tasks", "Health", "Feed","Telegram","Calendar","Weekly calendar","Exchange","Finance","Bitcoin","Control panel","Recorder","Calculator","Empty widget"} + +--variables-- local pos = 0 -local color = aio:colors() -local buttons,colors = {},{} -function on_alarm() - widgets = get_widgets() - if not prefs.widgets then - prefs.widgets = widgets.name - end - indexes = get_indexes(prefs.widgets, widgets.name) - ui:show_buttons(get_buttons()) -end - -function on_long_click(idx) - system:vibrate(10) - pos = idx - if idx > #prefs.widgets then - return - end - ui:show_context_menu({{"angle-left",""},{"ban",""},{"angle-right",""},{widgets.icon[indexes[idx]],widgets.label[indexes[idx]]}}) +function on_resume() + if next(settings:get()) == nil then + set_default_args() + end + ui:set_folding_flag(true) + local buttons,colors = get_buttons() + ui:show_buttons(buttons, colors) end function on_click(idx) - system:vibrate(10) - if idx > #prefs.widgets then - on_settings() - return - end - local widget = prefs.widgets[idx] - if not aio:is_widget_added(widget) then - aio:add_widget(widget, get_pos()) - aio:fold_widget(widget, false) - else - aio:remove_widget(widget) - end - on_alarm() + pos = idx + redraw() end -function on_dialog_action(data) - if data == -1 then - return - end - local tab = {} - for i,v in ipairs(data) do - tab[i] = widgets.name[v] - end - prefs.widgets = tab - on_alarm() -end - -function on_settings() - ui:show_checkbox_dialog("Select widgets", widgets.label, indexes) -end - -function get_indexes(tab1,tab2) - local tab = {} - for i1,v1 in ipairs(tab1) do - for i2,v2 in ipairs(tab2) do - if v1 == v2 then - tab[i1] = i2 - break - end - end - end - return tab -end - -function get_buttons() - local enabled_color = aio:colors().progress_good - local disabled_color = aio:colors().button - buttons,colors = {},{} - for i,v in ipairs(indexes) do - table.insert(buttons, "fa:" .. widgets.icon[v]) - table.insert(colors, widgets.enabled[v] and enabled_color or disabled_color) - end - --table.insert(buttons, "fa:gear") - --table.insert(colors, color.disabled_icon) - return buttons,colors -end - -function move(x) - local tab = prefs.widgets - if (pos*x == -1) or (pos*x == #tab) then - return - end - local cur = tab[pos] - tab[pos] = tab[pos+x] - tab[pos+x] = cur - prefs.widgets = tab - on_alarm() -end - -function remove() - local tab = prefs.widgets - table.remove(tab,pos) - prefs.widgets = tab - on_alarm() +function on_long_click(idx) + pos = idx + local tab = settings:get() + ui:show_context_menu({{"angle-left",""},{"ban",""},{"angle-right",""},{icons[get_checkbox_idx()[idx]]:gsub("fa:",""),names[get_checkbox_idx()[idx]]}}) end function on_context_menu_click(menu_idx) @@ -113,42 +47,90 @@ function on_context_menu_click(menu_idx) remove() elseif menu_idx == 3 then move(1) + elseif menu_idx == 4 then + redraw() end end -function on_widget_action(action, name) - on_alarm() +function on_dialog_action(data) + if data == -1 then + return + end + settings:set(data) + on_resume() end -function get_pos() - local name = aio:self_name() - local tab = aio:active_widgets() - for _,v in ipairs(tab) do - if v.name == name then - return v.position+1 - end - end - return 4 +function on_settings() + ui:show_checkbox_dialog("Select widgets", names, get_checkbox_idx()) end -function get_widgets() - local tab = {} - tab.icon = {} - tab.name = {} - tab.label = {} - tab.enabled = {} - for i,v in ipairs(aio:available_widgets()) do - if v.type == "builtin" then - table.insert(tab.icon, v.icon) - table.insert(tab.name, v.name) - table.insert(tab.label, v.label) - table.insert(tab.enabled, v.enabled) - end - end - local cal_widget = "my-calendar.lua" - table.insert(tab.icon, "calendar-days") - table.insert(tab.name, cal_widget) - table.insert(tab.label, "Месячный календарь") - table.insert(tab.enabled, aio:is_widget_added(cal_widget)) - return tab +--utilities-- + +function redraw() + local buttons,colors = get_buttons() + local checkbox_idx = get_checkbox_idx() + local widget = widgets[checkbox_idx[pos]] + if aio:is_widget_added(widget) then + aio:remove_widget(widget) + colors[pos] = disabled_color + else + aio:add_widget(widget) + colors[pos] = enabled_color + end + ui:show_buttons(buttons, colors) +end + +function set_default_args() + local args = {} + for i = 1, #widgets do + table.insert(args, i) + end + settings:set(args) +end + +function get_checkbox_idx() + local tab = settings:get() + for i = 1, #tab do + tab[i] = tonumber(tab[i]) + end + return tab +end + +function get_buttons() + local buttons,colors = {},{} + local checkbox_idx = get_checkbox_idx() + for i = 1, #checkbox_idx do + table.insert(buttons, icons[checkbox_idx[i]]) + local widget = widgets[checkbox_idx[i]] + if widget ~= nil then + if aio:is_widget_added(widget) then + table.insert(colors, enabled_color) + else + table.insert(colors, disabled_color) + end + end + end + return buttons,colors +end + +function move(x) + local tab = settings:get() + if (pos == 1 and x < 0) or (pos == #tab and x > 0) then + return + end + local cur = tab[pos] + local prev = tab[pos+x] + tab[pos+x] = cur + tab[pos] = prev + settings:set(tab) + local buttons,colors = get_buttons() + ui:show_buttons(buttons, colors) +end + +function remove() + local tab = settings:get() + table.remove(tab,pos) + settings:set(tab) + local buttons,colors = get_buttons() + ui:show_buttons(buttons, colors) end diff --git a/scripts.md5 b/scripts.md5 index 385b187..9ca7f08 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -f479d227b90a6f98f309841cdcce9f38 +6427267169ed17f29d737911edecfb91 diff --git a/scripts.zip b/scripts.zip index 6369f694eb3d4609f390ff18a98a629d09f399d5..658a06a752ee772a0cd789764743309484968311 100644 GIT binary patch delta 1585 zcmV-12G04ltpS~{0k9i04(C{jSVDK_Zjc2403i^QDKi~^BIy)nBIy)nb$AN^0R-p+ z000E&0{{TMS4(f(Mi9R1S1eSZrBKm`)1HjFKx)VBB|*>_@WC*M6*;69UhOiwOG|>` z{`Su7gAZADl0)l*Ih>vM%r{HrIa7QC?3~SSMAd+^%x;A%*I?$eJZBZy(umdxtw`p& zGYTb21EAP{HY(r|R~6HB&9-aguR7;6ig5$1HDE1N-j>_9-ciu=EN+@^1IpQA4YH-f zORau#tXy-|0CQ^?L|7#ZluquKth3=vYSpk(it?VJNOux!c5bZ=*?Olc1AF!-e=tJo z2Y>ni#>Qmco}A8S$SW~e$I(Nc&t_7WTryC6C7~*RN-e!9F7%nFZMHaRjczEdqS3mF z3YD<0XoQL+~X#Y?x@zwL}?}W_*SCmJwCbQW<#gi$SN^6S_!8~$r)bPqC~2d zeDCe>wzc80(z`%NVO^kVEh{VlInc`S(h;e&6E!)l1edz8k@D7@*!ZV)y4`Y|3v$ne z3~E4svX0w(e6sl(xO8ixYQUD`2}o!Rr}!~%P!%^La*H(VLZ^|eh2p9tYK8Nsg^EEM zP0q0M+Eftr%TDr80NAu{KYvQ471T>#*qWc=l$bo#4Bu_1=(VfD>*&N+c`Ul>tWenE zobnGW1rD2VpKoyrqlIzw{ERw~m%@}XGK^k-X%|Q;3q4~ekP4lM?yHLCDKEK+mRBHU zj8boC`g1I8z7eXk(b-xnAZC%h{n8<#qkG_f#q451MyH`E({^*f+5s=4!TI?`6{(HdR#Tb9@34d{;QStNqfg3@qaI{TZ zO`Ui%o7J5v{Z*n>ffJ8=JzLBe6E#z?bD0I_glg;=8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~yiKKxa}MHv3*Y9W z-1O%!_YMWNKm$pCY+}mfd$vXC))xL3oI1cp05&mLkN%%kIa&ro&deFLRKv!E)gH(= zPTUwOCm`55iqNgk*r(?qAHW=8|9V8bRSuqCcyFhWZtMCHqyEj}D)Q4HvOV6slF6#A z2`khqT2Iw?p@tgBpJtGfm$jRJIkl@&P1UXJbE#H6(+G_j48~P(0_pSu z>st&WrU8s_NOxlsv~dnI)mpt6=P{@xmsv(mbWNROmYrUCg6$!J10dr^DrF50{A=z9 zmMzKgp_X0m3W{F;7>~gbbbr8y%+JT);Tz}k@z?GXf=`~u?g>72KEqee^LbL4%bzQSj>t4a%FB~d6QvRD3dQy3X_3W9s;^Zlc82x1N=$=lL1T_lV4UM VlQ~x&0 Date: Tue, 9 Apr 2024 11:37:27 +0400 Subject: [PATCH 086/204] Update Widget Switcher script --- main/widgets-on-off.lua | 225 +++++++++++++++++++++------------------- scripts.md5 | 2 +- scripts.zip | Bin 22429 -> 22027 bytes 3 files changed, 118 insertions(+), 109 deletions(-) diff --git a/main/widgets-on-off.lua b/main/widgets-on-off.lua index 3fee690..f2d863a 100644 --- a/main/widgets-on-off.lua +++ b/main/widgets-on-off.lua @@ -1,43 +1,105 @@ -- name = "Widgets switcher" -- description = "Turns screen widgets on and off when buttons are pressed" -- type = "widget" --- arguments_help = "Don't change the arguments directly, use the long click menu." -- author = "Andrey Gavrilov" --- version = "2.1" +-- version = "3.0" ---constants-- - -local enabled_color = aio:colors().progress_good -local disabled_color = aio:colors().button - -local widgets = {"weather","weatheronly","clock","alarm","worldclock","monitor","traffic","player","apps","appbox","applist","appfolders","contacts","notify","dialogs","dialer","timer","stopwatch","mail","notes","tasks", "health", "feed","telegram","calendar","calendarw","exchange","finance","bitcoin","control","recorder","calculator","empty"} - -local icons = {"fa:user-clock","fa:sun-cloud","fa:clock","fa:alarm-clock","fa:business-time","fa:network-wired","fa:exchange","fa:play-circle","fa:robot","fa:th","fa:list","fa:folder","fa:address-card","fa:bell","fa:comment-alt-minus","fa:phone-alt","fa:chess-clock","fa:stopwatch","fa:at","fa:sticky-note","fa:calendar-check", "fa:heart-pulse", "fa:rss-square","fa:paper-plane","fa:calendar-alt","fa:calendar-week","fa:euro-sign","fa:chart-line","fa:coins","fa:wifi","fa:microphone-alt","fa:calculator-alt","fa:eraser"} - -local names = {"Clock & weather","Weather","Clock","Alarm","World clock","Monitor","Traffic","Player","Frequent apps","My apps","App list","App folders","Contacts","Notify","Dialogs","Dialer","Timer","Stopwatch","Mail","Notes","Tasks", "Health", "Feed","Telegram","Calendar","Weekly calendar","Exchange","Finance","Bitcoin","Control panel","Recorder","Calculator","Empty widget"} - ---variables-- +prefs = require "prefs" local pos = 0 +local buttons,colors = {},{} -function on_resume() - if next(settings:get()) == nil then - set_default_args() - end - ui:set_folding_flag(true) - local buttons,colors = get_buttons() - ui:show_buttons(buttons, colors) -end - -function on_click(idx) - pos = idx - redraw() +function on_alarm() + widgets = get_widgets() + if not prefs.widgets then + prefs.widgets = widgets.name + end + indexes = get_indexes(prefs.widgets, widgets.name) + ui:show_buttons(get_buttons()) end function on_long_click(idx) - pos = idx - local tab = settings:get() - ui:show_context_menu({{"angle-left",""},{"ban",""},{"angle-right",""},{icons[get_checkbox_idx()[idx]]:gsub("fa:",""),names[get_checkbox_idx()[idx]]}}) + system:vibrate(10) + pos = idx + if idx > #prefs.widgets then + return + end + ui:show_context_menu({{"angle-left",""},{"ban",""},{"angle-right",""},{widgets.icon[indexes[idx]],widgets.label[indexes[idx]]}}) +end + +function on_click(idx) + system:vibrate(10) + if idx > #prefs.widgets then + on_settings() + return + end + local widget = prefs.widgets[idx] + if not aio:is_widget_added(widget) then + aio:add_widget(widget, get_pos()) + aio:fold_widget(widget, false) + else + aio:remove_widget(widget) + end + on_alarm() +end + +function on_dialog_action(data) + if data == -1 then + return + end + local tab = {} + for i,v in ipairs(data) do + tab[i] = widgets.name[v] + end + prefs.widgets = tab + on_alarm() +end + +function on_settings() + ui:show_checkbox_dialog("Select widgets", widgets.label, indexes) +end + +function get_indexes(tab1,tab2) + local tab = {} + for i1,v1 in ipairs(tab1) do + for i2,v2 in ipairs(tab2) do + if v1 == v2 then + tab[i1] = i2 + break + end + end + end + return tab +end + +function get_buttons() + local enabled_color = aio:colors().progress_good + local disabled_color = aio:colors().button + buttons,colors = {},{} + for i,v in ipairs(indexes) do + table.insert(buttons, "fa:" .. widgets.icon[v]) + table.insert(colors, widgets.enabled[v] and enabled_color or disabled_color) + end + return buttons,colors +end + +function move(x) + local tab = prefs.widgets + if (pos*x == -1) or (pos*x == #tab) then + return + end + local cur = tab[pos] + tab[pos] = tab[pos+x] + tab[pos+x] = cur + prefs.widgets = tab + on_alarm() +end + +function remove() + local tab = prefs.widgets + table.remove(tab,pos) + prefs.widgets = tab + on_alarm() end function on_context_menu_click(menu_idx) @@ -47,90 +109,37 @@ function on_context_menu_click(menu_idx) remove() elseif menu_idx == 3 then move(1) - elseif menu_idx == 4 then - redraw() end end -function on_dialog_action(data) - if data == -1 then - return - end - settings:set(data) - on_resume() +function on_widget_action(action, name) + on_alarm() end -function on_settings() - ui:show_checkbox_dialog("Select widgets", names, get_checkbox_idx()) +function get_pos() + local name = aio:self_name() + local tab = aio:active_widgets() + for _,v in ipairs(tab) do + if v.name == name then + return v.position+1 + end + end + return 4 end ---utilities-- - -function redraw() - local buttons,colors = get_buttons() - local checkbox_idx = get_checkbox_idx() - local widget = widgets[checkbox_idx[pos]] - if aio:is_widget_added(widget) then - aio:remove_widget(widget) - colors[pos] = disabled_color - else - aio:add_widget(widget) - colors[pos] = enabled_color - end - ui:show_buttons(buttons, colors) -end - -function set_default_args() - local args = {} - for i = 1, #widgets do - table.insert(args, i) - end - settings:set(args) -end - -function get_checkbox_idx() - local tab = settings:get() - for i = 1, #tab do - tab[i] = tonumber(tab[i]) - end - return tab -end - -function get_buttons() - local buttons,colors = {},{} - local checkbox_idx = get_checkbox_idx() - for i = 1, #checkbox_idx do - table.insert(buttons, icons[checkbox_idx[i]]) - local widget = widgets[checkbox_idx[i]] - if widget ~= nil then - if aio:is_widget_added(widget) then - table.insert(colors, enabled_color) - else - table.insert(colors, disabled_color) - end - end - end - return buttons,colors -end - -function move(x) - local tab = settings:get() - if (pos == 1 and x < 0) or (pos == #tab and x > 0) then - return - end - local cur = tab[pos] - local prev = tab[pos+x] - tab[pos+x] = cur - tab[pos] = prev - settings:set(tab) - local buttons,colors = get_buttons() - ui:show_buttons(buttons, colors) -end - -function remove() - local tab = settings:get() - table.remove(tab,pos) - settings:set(tab) - local buttons,colors = get_buttons() - ui:show_buttons(buttons, colors) +function get_widgets() + local tab = {} + tab.icon = {} + tab.name = {} + tab.label = {} + tab.enabled = {} + for i,v in ipairs(aio:available_widgets()) do + if v.type == "builtin" then + table.insert(tab.icon, v.icon) + table.insert(tab.name, v.name) + table.insert(tab.label, v.label) + table.insert(tab.enabled, v.enabled) + end + end + return tab end diff --git a/scripts.md5 b/scripts.md5 index 9ca7f08..fdb9e77 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -6427267169ed17f29d737911edecfb91 +7b1a56f29cd6c2d3496a400722e257a3 diff --git a/scripts.zip b/scripts.zip index 658a06a752ee772a0cd789764743309484968311..697532979d19d2071c97a9a9dada933623daa0f1 100644 GIT binary patch delta 1192 zcmV;Z1Xuf=uK|m!0k9i04x?O&SVh{^E&c-l0ND$ZDKj2_@Dyeu@Dyfscnbgl1n2_* z00ig*005m<%Wms75M4`OLFjIzURj8Jy9(d}UG)Q6pbNtgXlY~1st<=o`f@nn_`J{u-1(jz$3p z^6CYUL`6$~WY>|`6W$*NttGNi1>~Zj@1eE2^xMT6a&q>H4*DdOx%^$U3f{;cbX1JX z(NafHy*K=$ddkuiwRJrn75p)6Cb5&r}2-Z@6%`YZxgSN^<*D`@p?72V5*V?1Xjd0i(MQXH1$hZ{8y5X#O$ys|X(xiXuHJqPEc2HD9zJ79g zUCfXrO%Nom&W7@~Z0^pxu{Ruh~3RKdA)=V7Dv)ii(vr8){ zhc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024 12:00:49 +0400 Subject: [PATCH 087/204] Move Widgets switcher out of main repo --- {main => community}/widgets-on-off.lua | 2 +- scripts.index | 1 - scripts.md5 | 2 +- scripts.zip | Bin 22027 -> 20841 bytes 4 files changed, 2 insertions(+), 3 deletions(-) rename {main => community}/widgets-on-off.lua (98%) diff --git a/main/widgets-on-off.lua b/community/widgets-on-off.lua similarity index 98% rename from main/widgets-on-off.lua rename to community/widgets-on-off.lua index f2d863a..2d8e8bf 100644 --- a/main/widgets-on-off.lua +++ b/community/widgets-on-off.lua @@ -73,7 +73,7 @@ function get_indexes(tab1,tab2) end function get_buttons() - local enabled_color = aio:colors().progress_good + local enabled_color = "#1976d2" local disabled_color = aio:colors().button buttons,colors = {},{} for i,v in ipairs(indexes) do diff --git a/scripts.index b/scripts.index index 1dea528..aa7d545 100644 --- a/scripts.index +++ b/scripts.index @@ -14,7 +14,6 @@ sys-info-widget.lua tasks-menu.lua unit-converter.lua uptimerobot-widget.lua -widgets-on-off.lua wikipedia-widget.lua year_progress-widget.lua currency-ru-widget.lua diff --git a/scripts.md5 b/scripts.md5 index fdb9e77..f28803d 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -7b1a56f29cd6c2d3496a400722e257a3 +d97c6117fe0a3a43f55564d175038395 diff --git a/scripts.zip b/scripts.zip index 697532979d19d2071c97a9a9dada933623daa0f1..c48ced14a636e2f5ca17025d40f291215e606934 100644 GIT binary patch delta 97 zcmeBP!}xL$;|6Kt&8g;cGLvry%P|QWPyQVo!Ng!TIW#1O*~^?^@iF60FenFSpWb4 delta 1248 zcmV<61Rwk9q5+Gn0k9i0f1_N9SVh{^E&c-l0ND!w01^Nk0C#C*XJvGAEpKiuZ)RpL zY;|E(R0#kBBJdPuBJdPub$AN^0R-p+000E&0{{S>R?BYdHV|D)UqR?@q+VHweY*
>iVpfDmAU*~vouI8M|MzDL%x1;dR@$rB~1_{uH-lJe{BJ0k|@yl`e|ZJCBdCW z3Jq6XpFs@y`+G*kk;95Zr?WE4FyPsNim-J=#g3;y4LBL<+4)%P(24!N3?xnuz+>9S z#{%G=VEqX?6ADz)gVszO&9mF92(wEoCxW!_F{DH5dyvO870GB(bg0mbU<}Dlmk1^!@Lj+q!xjfd?UgRy+ z)P>FL$aYIs>%~-XVbSzpODs(~ENE7anCOIEC{w*tMOx{+M9v-C&q`!B?!CHsAt8I3 zeC77^&2DLVg68EQuO3sL{Rtcz9ZY8T3bW}|hN_&af1j2pIWjNV3fX@t}adM7JRYru(qE2eq+& z48X0;OmKss2M%p*n=5)?QqMKoyr?cp9!=k`k5aZ1p_cVuNI5fU@=4!b$gA*ZHnkFM zbXQFDf1q?8l#r~W&l#yI61AFfU(6+(xqD)Ggve^ATMQWgVlckMd}YjL&n%{2rE{fP( zXY8AK$R{ut*ncc&56aQ=2k*nsa9!9fCAohHe2V-wH$qGHA9kk5df;7c&UdPN3p;~Q z{x&kKyeYLhDm9yGw#-ahs+{VrGvS9q$o;WGFPL%Z`x>upSxjr=*9E^Pw&&vnceZ9H zNJkGW9Bm7qoPDW&I*u&nkuq-B?xv^s+@~sjcOC}Dak^wTkWtSFzLh9q)?$&vxLf+5 zEpzxGG`h_)k4I&={I*z%ZfN2E0<#e_C>%YbT!~mk+SM)o0{{To3jhET02lxO00001 z0001_fe|wR0C#C*XJvGAEpKiuZ)RpLY;|E(R0RM7BJdPuld()2lQ~Zw16wx$lP)tC zlW|W#14=polN~l2lh02;0+c(G5l~tJ5J;14P+9^~N|VV@S^@}6lO<6$4i^9y00#&F K0Paly0000h^*&_) -- 2.43.0 From df54b56f503e3c78bc8bc1a2be27be09aa3a69c7 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 9 Apr 2024 15:40:28 +0400 Subject: [PATCH 088/204] Move Kodi remote and Uptimerobot scripts out of the main repo --- {main => community}/kodi-remote-widget.lua | 0 {main => community}/uptimerobot-widget.lua | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {main => community}/kodi-remote-widget.lua (100%) rename {main => community}/uptimerobot-widget.lua (100%) diff --git a/main/kodi-remote-widget.lua b/community/kodi-remote-widget.lua similarity index 100% rename from main/kodi-remote-widget.lua rename to community/kodi-remote-widget.lua diff --git a/main/uptimerobot-widget.lua b/community/uptimerobot-widget.lua similarity index 100% rename from main/uptimerobot-widget.lua rename to community/uptimerobot-widget.lua -- 2.43.0 From c1e934c7a1b85f6f2c37de88f0f2edd4f9a69d80 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 9 Apr 2024 15:40:56 +0400 Subject: [PATCH 089/204] Update scripts zip --- scripts.index | 2 -- scripts.md5 | 2 +- scripts.zip | Bin 20841 -> 18590 bytes 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts.index b/scripts.index index aa7d545..b3212d9 100644 --- a/scripts.index +++ b/scripts.index @@ -5,7 +5,6 @@ contacts-menu.lua dice-widget.lua facts-widget.lua inspiration-quotes-widget.lua -kodi-remote-widget.lua public-ip-widget.lua quotes-widget.lua shell-widget.lua @@ -13,7 +12,6 @@ sunrise-sunset-widget.lua sys-info-widget.lua tasks-menu.lua unit-converter.lua -uptimerobot-widget.lua wikipedia-widget.lua year_progress-widget.lua currency-ru-widget.lua diff --git a/scripts.md5 b/scripts.md5 index f28803d..4d6e642 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -d97c6117fe0a3a43f55564d175038395 +252c5d32132eb76cffcf0d4dfb740299 diff --git a/scripts.zip b/scripts.zip index c48ced14a636e2f5ca17025d40f291215e606934..57b16e94a23f06753aebfefad014d454a2cd3638 100644 GIT binary patch delta 161 zcmaF4h;iOT#tlD3HXBRwi*1%R{w*=tSW<{jf&l~=fp|&ddy&bLd?Hx%#TXbSKlB!x z%;Iayv`>7pvu_BKt>omHzOhVZ(vyGqhBMuinH=aB#MGiNd8wbpWJ`ZJ=6_lYll6?n zCl~rVFu&Dhm@EradEVcF$y|T3U_cbpX6wnhKHv7Vwh-<(x5SRGYFZ;T3N&iW9D%ge;n8JsWXLJ8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wh(+6Q zik$?;&{(c|c@U5za|HO)SXTd^B>CTXozo!Dzj0+hJ`%7n*5f>^3B()Qa)IC=fKN>l y;Km?0FKPqE7(7=i5(M< Date: Wed, 10 Apr 2024 20:01:46 +0400 Subject: [PATCH 090/204] [calendar-menu] use calendar colors instead of event colors --- main/calendar-menu.lua | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/main/calendar-menu.lua b/main/calendar-menu.lua index 5af4289..7cbe4ae 100644 --- a/main/calendar-menu.lua +++ b/main/calendar-menu.lua @@ -4,15 +4,18 @@ -- type = "drawer" -- aio_version = "4.7.99" -- author = "Evgeny Zobnin" --- version = "1.0" +-- version = "1.1" local fmt = require "fmt" local have_permission = false local events = {} +local calendars = {} function on_drawer_open() events = calendar:events() + calendars = calendar:calendars() + add_cal_colors(events, calendars) if events == "permission_error" then calendar:request_permission() @@ -25,14 +28,25 @@ function on_drawer_open() return end - lines = map(events, function(it) - local date = fmt.colored(format_date(it.begin), it.color) + lines = map(function(it) + local date = fmt.colored(format_date(it.begin), it.calendar_color) return date..fmt.space(4)..it.title - end) + end, events) drawer:show_ext_list(lines) end +function add_cal_colors(events, cals) + for i, event in ipairs(events) do + for _, cal in ipairs(cals) do + if event.calendar_id == cal.id then + event.calendar_color = cal.color + break + end + end + end +end + function format_date(date) if system.format_date_localized then return system:format_date_localized("dd.MM", date) @@ -53,11 +67,3 @@ function on_long_click(idx) calendar:open_event(events[idx].id) end -function map(tbl, f) - local ret = {} - for k,v in pairs(tbl) do - ret[k] = f(v) - end - return ret -end - -- 2.43.0 From 076af78f837f6b99a593dc7ff48703e8b1f15f62 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 10 Apr 2024 20:02:27 +0400 Subject: [PATCH 091/204] Update scripts zip --- scripts.md5 | 2 +- scripts.zip | Bin 18590 -> 18640 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts.md5 b/scripts.md5 index 4d6e642..d57d46e 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -252c5d32132eb76cffcf0d4dfb740299 +a262726ee83c9e9f7e45a994c01d4fc1 diff --git a/scripts.zip b/scripts.zip index 57b16e94a23f06753aebfefad014d454a2cd3638..1a273addec10597e955c0b2f641e6198f9a04ad4 100644 GIT binary patch delta 996 zcmbO?k@3PrM!o=VW)=|!1_lm>30_?h6ZzEH=PQb(0r5tggN)1@)`@Lm3gF}uT+kJ< zt$XbhQziz653G~pxMk`WZWl`f;nE6j21b?_%nS@*Vr__T{%r%Ey}!db^tf&~C@pYk zT*z1@RrY4(cHZU%5hYGnrp0*r&F206{_^xx>yvq(6(@Syefl`@Q<=BQ`$n6|pS0gQ zaIN#?FVgAG{bC?;@1{!n25y7iV+R*ay7#>*M853+=MvK;S69`mKg-eilES*_x#AST zS@jMkg&}WPZY{Ct|H55c)iv*;+|+N!@|QE8F#fsjn^5WpT><_t3w65ub~-J2yVf|f zLOzgL^KN#T>`%@c47=PXPtbkOqmr-m&!_Ic=d{jpBeAy{voEZfq;n}fiy`tVYoY%! z{|&KQRK6QU_MJE;a-=okT>UYrtD5OOoMy(`^qeHN?VR3up>o^xWC>WYogB zKaX&7ywE6C z{v=b0ptz9k;%V6i*O-z0xV}ZO#2hw<`9|bhx+DdDb`n>ED)1UwF#5bJN^O?f-*r z*H2G+d)syLBwi~}YTJCCcQO;0kt)y!PJf%f3C@HtCJE1gFmy$&AdD=rZV2Otcq@d_ zAo&5pD3+cLVF=2uVFnv`K%tTg%&^h^0I@<}&lRGkT)&bBEcMyi9wKFGw-F-s(tZmg z3n*($Ug&7b0?Hec^_`_Be{~E(&lI6fS}dRp0hXWVB*%P=mtpcoUXjU{og5hBCW|B}rE@6xxCSP_5Wz3(f=^DqFF}cGvf{9yp@*~$E z=4}cLlNTz8PWEwgU^392+~*d-EU(8fnM+T4GK;$dW9DR6_h`nalNY*2GpXB6{^uUW Rcz1H7hdtY2M_`_2001zSst^DG delta 936 zcmcaGk#XKcM!o=VW)=|!1_llW7Z;82iG1qp4oiNeh%6D_XmgN}8Axwp3gG0^jdl;; z_{%M!xlR&Y3}%u&g^b$_Z&+W^O1R(u>#UH3qosG$V(a>(^Vb~R^}6ot>^C{| z!Q4Z!Z&q(Y&b!YJ`!5_n-oo>4g)c{)H2;EgPulNkhX_W8)-0QUYSDyS!V|X@+oe2s z-oWPZGCuvq3HJos8GO0xa&~T+a8c(^=bwMUB5xPWvX~yGqnWykJ@hK;$MbWne7AWE z^1I92wmiBzT0&A{v9ISH!TJy%p7VE1T2W9Ey5>U$1f1A<>ombK!Xye%hR?%1#DG4H+fxwnEJtZg}j}Uxy#JCR|RqW`V*6P;t=D*4eP2hycbXU6nEkGJEOa& z_f2`Xe(A&;bF@U>Z_ZhIw|y=9R^h{Y_WxWl$uqIpM`8M}3DS>|$@$_kJ37jI067hZT>ZvULP!-8Rt zAH6(P`+s`I|5XL=| zXFG>7dQbl7oW%TIgkiFssQBbu7Y9cD$?IIg823$Pbq!^-ogD2N$7nWrmum#mO_|9e zZb6JKlhfV8nf_@_KHwI?{8pD?vW=efWHWaMM)S$#?$L~!Ctr4tX8LM7*}x-;arNYG N4|}$Wj=+4$007NufE@q; -- 2.43.0 From a94a44c43ddfef6f6a8215dada419e684c822485 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 14 Apr 2024 15:47:42 +0400 Subject: [PATCH 092/204] update amdroid widget --- community/amdroid-nextalarm-app-widget.lua | 17 +++++++++++------ samples/progress_sample.lua | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 samples/progress_sample.lua diff --git a/community/amdroid-nextalarm-app-widget.lua b/community/amdroid-nextalarm-app-widget.lua index 2f067ce..63c4f59 100644 --- a/community/amdroid-nextalarm-app-widget.lua +++ b/community/amdroid-nextalarm-app-widget.lua @@ -2,20 +2,20 @@ -- description = "AIO wrapper for the Amdroid next alarm app widget" -- type = "widget" -- author = "Theodor Galanis" --- version = "1.0" +-- version = "1.0.2" -- foldable = "false" -- uses_app = "com.amdroidalarmclock.amdroid" local prefs = require "prefs" local next_alarm = "" -local w_bridge = nil +local accent="#FFFFFF" function on_resume() if not widgets:bound(prefs.wid) then setup_app_widget() end - + accent = aio:colors().accent widgets:request_updates(prefs.wid) end @@ -26,11 +26,16 @@ function on_app_widget_updated(bridge) w_bridge = bridge if next_alarm ~= nil - then - ui:show_table({{" ", "%%fa:alarm-clock%% "..next_alarm, " "}}, 0, true) + then + my_gui=gui{ + {"text", " %%fa:alarm-clock%% "..next_alarm.."", {gravity="center_h", color=accent}} + } else - ui:show_text("Empty") + my_gui=gui{ + {"text", "Empty", {gravity="center_h" }} + } end + my_gui.render() end function on_click(idx) diff --git a/samples/progress_sample.lua b/samples/progress_sample.lua new file mode 100644 index 0000000..642fadc --- /dev/null +++ b/samples/progress_sample.lua @@ -0,0 +1,20 @@ +function on_resume() + ui:show_lines{ + "Set progress 25%", + "Set progress 50%", + "Set progress 75%", + "Set progress 100%", + } +end + +function on_click(idx) + if idx == 1 then + ui:set_progress(0.25) + elseif idx == 2 then + ui:set_progress(0.5) + elseif idx == 3 then + ui:set_progress(0.75) + elseif idx == 4 then + ui:set_progress(1) + end +end -- 2.43.0 From 025032cbe9ed470e1387fd6ea1dc5b8d77dc8909 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 16 Apr 2024 08:39:18 +0400 Subject: [PATCH 093/204] Fix error in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc9399f..2ed337f 100644 --- a/README.md +++ b/README.md @@ -353,7 +353,7 @@ end To change the action of the settings icon in the widget's edit menu, you can add the on_settings() function to the script. It will be called every time the user presses the icon. ``` -function on_action() +function on_settings() ui:show_toast("Settings icon clicked!") end ``` -- 2.43.0 From 3cbe02774fff1d6c1590d1cb6806e593afcf2d21 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 18 Apr 2024 14:41:45 +0400 Subject: [PATCH 094/204] README: add info about ui:set_rpogress() --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2ed337f..ce3e922 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ The type of script is determined by the line (meta tag) at the beginning of the ### 5.2.1 * Added support for complex UIs +* Added `ui:set_progress()` function ### 5.2.0 @@ -113,7 +114,8 @@ _Available only in widget scripts._ * `ui:default_title()` - returns the standard widget title (set in the `name` metadata); * `ui:set_title()` - changes the title of the widget, should be called before the data display function (empty line - reset to the standard title); * `ui:set_folding_flag(boolean)` - sets the flag of the folded mode of the widget, the function should be called before the data display functions; -* `ui:folding_flag()` - returns folding flag. +* `ui:folding_flag()` - returns folding flag; +* `ui:set_progress(float)` - sets current widget progress (like in Player and Health widgets). When you click on any element of the interface, the `on_click(number)` callback will be executed, where number is the ordinal number of the element. A long click calls `on_long_click(number)`. For example, if you use `ui:show_buttons` to show three buttons, then clicking the first button will call `on_click` with argument 1, the second with arguments 2, and so on. If there is only one element on the screen, the argument will always be equal to one and can be omitted. -- 2.43.0 From 3242d9c24f009c59259f02309a2dc10df36fd947 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 18 Apr 2024 14:42:11 +0400 Subject: [PATCH 095/204] Update Rich GUI sample --- samples/rich-gui-sample.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/samples/rich-gui-sample.lua b/samples/rich-gui-sample.lua index b045508..6776379 100644 --- a/samples/rich-gui-sample.lua +++ b/samples/rich-gui-sample.lua @@ -5,11 +5,18 @@ function on_resume() if app == nil then return end my_gui = gui{ - {"text", "Title", {size = 19, color = "#ff0000", gravity = "center_h"}}, + {"icon", "fa:smile", {size = 15, color = "#aaaaaa", gravity = "center_v"}}, + {"text", "This is", {size = 25, color = "#ff0000", gravity = "center_h|center_v"}}, + {"spacer", 2}, + {"text", "TITLE", {size = 20, color = "#ff0000", gravity = "anchor_prev|center_v"}}, + {"spacer", 2}, + {"icon", "fa:smile", {size = 15, color = "#aaaaaa", gravity = "center_v"}}, {"new_line", 2}, {"text", "Hello, World", {size = 21}}, {"spacer", 2}, {"text", "Center small text", {size = 8, gravity = "center_v"}}, + {"spacer", 1}, + {"icon", "fa:plus", {size = 8, gravity="center_v"}}, {"text", "Top right text", {size = 8, gravity = "top|right"}}, {"new_line", 1}, {"button", "Ok", {color = "#00aa00"}}, @@ -22,6 +29,12 @@ function on_resume() {"new_line", 2}, {"button", "Center button", {gravity = "center_h"}}, {"new_line", 2}, + {"button", "Whole width button", {expand = true}}, + {"spacer", 2}, + {"button", "fa:home"}, + {"spacer", 2}, + {"button", "fa:check"}, + {"new_line", 2}, {"icon", "fa:microphone", {size = 17, color = "#00ff00", gravity = "center_v"}}, {"spacer", 4}, {"icon", "fa:microphone", {size = 22, gravity = "center_v"}}, @@ -45,7 +58,7 @@ function on_apps_changed() on_resume() end -function on_click(idx, extra) +function on_click(idx) local elem_name = my_gui.ui[idx][1] if elem_name == "text" then -- 2.43.0 From 5eea6d8b9133ff1db2ff5e62931ecbef262c5402 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 18 Apr 2024 14:47:18 +0400 Subject: [PATCH 096/204] Move useless scripts to samples folder --- community/meta-widget.lua | 1 + {community => samples}/apps-widget.lua | 0 {community => samples}/btc-widget.lua | 0 {community => samples}/calendar-search.lua | 0 {community => samples}/cloud-file-widget.lua | 0 {community => samples}/notes-widget.lua | 0 {community => samples}/rss-widget.lua | 0 {community => samples}/screen-state-menu.lua | 0 8 files changed, 1 insertion(+) rename {community => samples}/apps-widget.lua (100%) rename {community => samples}/btc-widget.lua (100%) rename {community => samples}/calendar-search.lua (100%) rename {community => samples}/cloud-file-widget.lua (100%) rename {community => samples}/notes-widget.lua (100%) rename {community => samples}/rss-widget.lua (100%) rename {community => samples}/screen-state-menu.lua (100%) diff --git a/community/meta-widget.lua b/community/meta-widget.lua index d455b0f..f2be273 100644 --- a/community/meta-widget.lua +++ b/community/meta-widget.lua @@ -1,4 +1,5 @@ -- name = "Meta widget" +-- description = "Widget of widgets" -- type = "widget" -- author = "Andrey Gavrilov" -- version = "1.0" diff --git a/community/apps-widget.lua b/samples/apps-widget.lua similarity index 100% rename from community/apps-widget.lua rename to samples/apps-widget.lua diff --git a/community/btc-widget.lua b/samples/btc-widget.lua similarity index 100% rename from community/btc-widget.lua rename to samples/btc-widget.lua diff --git a/community/calendar-search.lua b/samples/calendar-search.lua similarity index 100% rename from community/calendar-search.lua rename to samples/calendar-search.lua diff --git a/community/cloud-file-widget.lua b/samples/cloud-file-widget.lua similarity index 100% rename from community/cloud-file-widget.lua rename to samples/cloud-file-widget.lua diff --git a/community/notes-widget.lua b/samples/notes-widget.lua similarity index 100% rename from community/notes-widget.lua rename to samples/notes-widget.lua diff --git a/community/rss-widget.lua b/samples/rss-widget.lua similarity index 100% rename from community/rss-widget.lua rename to samples/rss-widget.lua diff --git a/community/screen-state-menu.lua b/samples/screen-state-menu.lua similarity index 100% rename from community/screen-state-menu.lua rename to samples/screen-state-menu.lua -- 2.43.0 From eea5047a2a6ce1fd510a8bf2f866327442cdcd62 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 21 Apr 2024 08:50:22 +0400 Subject: [PATCH 097/204] Update Google search and Quick actions scripts --- community/google-search-app-widget.lua | 80 ++++++++-- community/quickactions-widget.lua | 197 +++++++++++++------------ 2 files changed, 168 insertions(+), 109 deletions(-) diff --git a/community/google-search-app-widget.lua b/community/google-search-app-widget.lua index 6804f6d..a8adfb9 100644 --- a/community/google-search-app-widget.lua +++ b/community/google-search-app-widget.lua @@ -2,38 +2,96 @@ -- description = "AIO wrapper for the Google search app widget" -- type = "widget" -- author = "Theodor Galanis" --- version = "1.01" +-- version = "2.0" -- foldable = "false" --- uses_app: "com.google.android.googlequicksearchbox"" +-- uses_app: "com.google.android.googlequicksearchbox" local prefs = require "prefs" -prefs._name = "google" -local buttons_labels = {" G ", "fa:magnifying-glass", "fa:microphone", "fa:camera"} -local buttons_targets = {"image_7", "image_4", "image_9", "image_10"} local w_bridge = nil +local gravs = {} +local indices = {} -function on_resume() +function on_alarm() if not widgets:bound(prefs.wid) then setup_app_widget() end - + if not prefs.mode then + prefs.mode = 1 + end + mode = prefs.mode + gravs = {"left", "right"} + indices = {1, 3, 5, 7} + if mode == 2 then + gravs= reverse(gravs) + indices = reverse(indices) + end widgets:request_updates(prefs.wid) end function on_app_widget_updated(bridge) w_bridge = bridge - ui:show_buttons(buttons_labels) + local tab = { + {"button", "            %%fa:magnifying-glass%%          ", {gravity = gravs[1]}}, + {"spacer", 2}, + {"button", "    %%fa:asterisk%%  ", {gravity = gravs[2]}}, + {"spacer", 2}, + {"button", "    %%fa:microphone%%  "}, + {"spacer", 2}, + {"button", "    %%fa:camera%%  "} + } + + if mode==1 then + my_gui = gui(tab) + else + my_gui =gui(reverse(tab)) + end + + my_gui.render() end function on_click(idx) - w_bridge:click(buttons_targets[idx]) + if idx == indices[1] then + w_bridge:click("image_4") + elseif idx == indices[2] then + w_bridge:click("image_7") + elseif idx == indices[3] then + w_bridge:click("image_9") + elseif idx == indices[4] then + w_bridge:click("image_10") + else return + end +end + +function on_settings() + local tab = {"Left-handed mode", "Right-handed mode"} + ui:show_radio_dialog("Select mode", tab, mode) +end + +function on_long_click(idx) + if idx == indices[1] then + ui:show_toast("Google search") + elseif idx == indices[2] then + ui:show_toast("Google discover") + elseif idx == indices[3] then + ui:show_toast("Google voice search") + elseif idx == indices[4] then + ui:show_toast("Google Lens") + end +end + +function on_dialog_action(data) + if data == -1 then + return + end + prefs.mode = data + on_alarm() end function setup_app_widget() local id = widgets:setup("com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.SearchWidgetProvider") - - if (id ~= nil) then + + if (id ~= nil) then prefs.wid = id else ui:show_text("Can't add widget") diff --git a/community/quickactions-widget.lua b/community/quickactions-widget.lua index 0c0ddd2..a30468b 100644 --- a/community/quickactions-widget.lua +++ b/community/quickactions-widget.lua @@ -1,44 +1,49 @@ -- name = "Quick Actions" -- type = "widget" --- description = "Launcher selected actions widget" --- arguments_help = "Long click button for options, open widget settings for list of buttons" +-- description = "Launcher selected actions widget - long click button for options, open widget settings for list of buttons" --foldable = "true" -- author = "Theodor Galanis" --- version = "2.5" +-- version = "3.0" -md_colors = require "md_colors" +prefs = require "prefs" +prefs._name = "quickactions" -local icons = { "fa:pen", "fa:edit", "fa:indent", "fa:bars", "fa:sliders-h", "fa:redo", "fa:power-off", "fa:bring-forward", "fa:eraser", "fa:tools", "fa:layer-minus", "fa:layer-group", "fa:user-shield", "fa:lock", "fa:chevron-down", "fa:chevron-up", "fa:notes-medical", "fa:circle-dot", "fa:envelope", "fa:square-full", "fa:microphone", "fa:hand", "fa:search"} +local actions = { "quick_menu", "settings", "apps_menu", "ui_settings", "headers", "quick_apps_menu", "refresh", "restart", "notify", "clear_notifications", "quick_settings", "show_recents", "private_mode", "screen_off", "fold", "unfold", "scroll_down", "scroll_up", "add_note", "add_task", "add_purchase", "shortcuts", "send_mail", "voice", "one_handed", "right_handed", "camera", "flashlight", "dialer", "search"} -local names = {"Quick menu", "Quick apps menu", "Applications menu", "Toggle headers", "Settings", "Screen refresh", "Restart AIO launcher", "Notifications panel", "Clear notifications", "Quick settings", "Fold all widgets", "Unfold all widgets", "Private mode", "Screen off", "Scroll down", "Scroll up", "Add note", "Start audio recording", "Send mail", "Recent apps", "Voice command", "One-handed mode", "Search"} +local icons = { "fa:ellipsis-vertical", "fa:sliders-h", "fa:indent", "fa:paintbrush", "fa:bars", "fa:share-from-square", "fa:redo", "fa:power-off", "fa:bring-forward", "fa:eraser", "fa:square-ellipsis", "fa:square-full", "fa:user-shield", "fa:lock", "fa:layer-minus", "fa:layer-group", "fa:chevron-down", "fa:chevron-up", "fa:notes-medical", "fa:list-check", "fa:tag", "fa:share", "fa:envelope", "fa:microphone", "fa:hand", "fa:right-to-bracket", "fa:camera", "fa:brightness", "fa:phone", "fa:search"} -local colors = { md_colors.purple_800, md_colors.purple_600, md_colors.amber_900, md_colors.orange_900, md_colors.blue_900, md_colors.deep_purple_800, md_colors.grey_600, md_colors.green_900, md_colors.green_900, md_colors.blue_800, md_colors.pink_300, md_colors.pink_A200, md_colors.green_600, md_colors.grey_800, md_colors.teal_700, md_colors.teal_800, md_colors.orange_700, md_colors.red_800, md_colors.red_900, md_colors.deep_purple_700, md_colors.blue_700, md_colors.amber_800, md_colors.blue_grey_700} - - local actions = { "quick_menu", "quick_apps_menu", "apps_menu", "headers", "settings", "refresh", "restart", "notify", "clear_notifications", "quick_settings", "fold", "unfold", "private_mode", "screen_off", "scroll_down", "scroll_up", "add_note", "start_record", "send_mail", "show_recents", "voice", "one_handed", "search"} +local cols = { "#6A1B9A", "#4527A0", "#8E24AA", "#FF6F00", "#E65100", "#0D47A1", "#546E7A", "#1B5E20", "#689F38", "#1565C0", "#F06292", "#0073DD", "#00796B", "#424242", "#3F51B5", "#3F51B5", "#AB47BC", "#AB47BC", "#D81B60", "#F57C00", "#9E9D24", "#00838F", "#B71C1C", "#512DA8", "#795548", "#5C6BC0", "#FF5252", "#FF8F00", "#B388FF", "#37474F"} local pos = 0 +local buttons,colors = {},{} -function on_resume() - if next(settings:get()) == nil then - set_default_args() - end - local buttons,colors = get_buttons() - ui:show_buttons(buttons, colors) +function on_alarm() + args = get_args() + if not prefs.args then + prefs.args = args.action + end + indexes = get_indexes(prefs.args, args.action) + ui:show_buttons(get_buttons()) end function on_click(idx) - pos = idx - redraw() + if idx > #prefs.args then + on_settings() + return + end + local action = prefs.args[idx] + aio:do_action(action) + on_alarm() end function on_long_click(idx) - pos = idx - local tab = settings:get() - label = get_label(actions[get_checkbox_idx()[idx]]) - if label == nil then - label = names[get_checkbox_idx()[idx]] - end - ui:show_context_menu({{"angle-left",""},{"ban",""},{"angle-right",""},{icons[get_checkbox_idx()[idx]]:gsub("fa:",""),label}}) + local label = "" + pos = idx + if idx > #prefs.args then + return + end + label = get_label(args.action[indexes[idx]]) + ui:show_context_menu({{"angle-left",""},{"ban",""},{"angle-right",""},{args.icon[indexes[idx]]:gsub("fa:",""),label}}) end function on_context_menu_click(menu_idx) @@ -48,96 +53,92 @@ function on_context_menu_click(menu_idx) remove() elseif menu_idx == 3 then move(1) - elseif menu_idx == 4 then - redraw() end end function on_dialog_action(data) - if data == -1 then - return - end - settings:set(data) - on_resume() + if data == -1 then + return + end + local tab = {} + for i,v in ipairs(data) do + tab[i] = args.action[v] + end + prefs.args = tab + on_alarm() end function on_settings() -axions = aio:actions() -lab = {} -for i = 1, #axions do -lav = get_label(actions[i]) - if lav == nil then - table.insert(lab,names[i]) - else - table.insert(lab, lav) - end - end - ui:show_checkbox_dialog("Select actions", lab, get_checkbox_idx()) + local labels = {} + for i = 1, #icons do + table.insert(labels, get_label(args.action[i])) + end + ui:show_checkbox_dialog("Select actions", labels, indexes) end --utilities-- -function redraw() - local buttons,colors = get_buttons() - local checkbox_idx = get_checkbox_idx() - local action = actions[checkbox_idx[pos]] -aio:do_action(action) - ui:show_buttons(buttons, colors) -end - -function set_default_args() - local args = {} - for i = 1, #actions do - table.insert(args, i) - end - settings:set(args) -end - -function get_checkbox_idx() - local tab = settings:get() - for i = 1, #tab do - tab[i] = tonumber(tab[i]) - end - return tab -end - -function get_buttons() - local buttons,bcolors = {},{} - local checkbox_idx = get_checkbox_idx() - for i = 1, #checkbox_idx do - table.insert(buttons, icons[checkbox_idx[i]]) - table.insert(bcolors, colors[checkbox_idx[i]]) - end - return buttons,bcolors -end - function move(x) - local tab = settings:get() - if (pos == 1 and x < 0) or (pos == #tab and x > 0) then - return - end - local cur = tab[pos] - local prev = tab[pos+x] - tab[pos+x] = cur - tab[pos] = prev - settings:set(tab) - local buttons,colors = get_buttons() - ui:show_buttons(buttons, colors) + local tab = prefs.args + if (pos*x == -1) or (pos*x == #tab) then + return + end + local cur = tab[pos] + tab[pos] = tab[pos+x] + tab[pos+x] = cur + prefs.args = tab + on_alarm() end function remove() - local tab = settings:get() - table.remove(tab,pos) - settings:set(tab) - local buttons,colors = get_buttons() - ui:show_buttons(buttons, colors) + local tab = prefs.args + table.remove(tab,pos) + prefs.args = tab + on_alarm() end + function get_label(name) -axions = aio:actions() - for _, action in ipairs(axions) do - if action["name"] == name then - return action["label"] + local lab="" + local axions = aio:actions() + if name == "clear_notifications" then + lab = aio:res_string("clear_notifications","Clear notifications") + else for _, action in ipairs(axions) do + if action["name"] == name then + lab = action["label"] + end end - end -end \ No newline at end of file +end +return lab +end + +function get_args() + local tab = {} + tab.action = actions + tab.icon = icons + tab.color = cols + return tab +end + +function get_buttons() + buttons,colors = {},{} + for i,v in ipairs(indexes) do + table.insert(buttons, args.icon[v]) + table.insert(colors, args.color[v]) + end + return buttons,colors +end + + +function get_indexes(tab1,tab2) + local tab = {} + for i1,v1 in ipairs(tab1) do + for i2,v2 in ipairs(tab2) do + if v1 == v2 then + tab[i1] = i2 + break + end + end + end + return tab +end -- 2.43.0 From 195d205a939ffdb28799782deb973f6821793db7 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 23 Apr 2024 08:11:47 +0400 Subject: [PATCH 098/204] Update rich ui README to reflect 5.2.2 changes --- README_RICH_UI.md | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/README_RICH_UI.md b/README_RICH_UI.md index 5a43e8b..be22686 100644 --- a/README_RICH_UI.md +++ b/README_RICH_UI.md @@ -28,7 +28,7 @@ This example is already useful, but it's too plain. Let's add some colors and va {"button", "Button #2", {color = "#0000ff"}}, ``` -To change the size of a line, we used the table `{size = 21}`. This is the standard approach if a command has more than one parameter, then all other arguments are passed in the table. To make the text italic, we used the HTML tag ``. The "text" command supports many tags for text transformation. The color of the buttons is also changed using a table. +To change the size of the text, we used the table `{size = 21}`. This is the standard approach if a command has more than one parameter, then all other arguments are passed in the table. To make the text italic, we used the HTML tag ``. The "text" command supports many tags for text transformation. The color of the buttons is also changed using a table. It's more interesting now, but again, an interface where all elements are grouped on the left side may not always be suitable. We need a way to align elements on the right side of the screen or in the center. Let's make the first line be in the middle of the line (kind of like a title), and the second button - on the right side: @@ -45,12 +45,12 @@ It's more interesting now, but again, an interface where all elements are groupe Here we used the `gravity` parameter to change the location of the element in the line. Three things are important to know about `gravity`: 1. It changes the position of the element only within the current line; -2. Possible `gravity` values: `left`, `top`, `right`, `bottom`, `center_h` (horizontal centering), `center_v` (vertical centering); +2. Possible `gravity` values: `left`, `top`, `right`, `bottom`, `center_h` (horizontal centering), `center_v` (vertical centering) and `anchor_prev`; 3. `Gravity` values can be combined, for example, to display a text element in the top right corner of the current line, you can specify `gravity = "top|right"`; Also, there are two limitations to know about: -1. The `center_h` value is applied to each element separately, meaning if you add two lines with the gravity value `center_h` in one line, they will not both be grouped and displayed in the center, but instead, they will split the screen in half and be displayed each in the center of its half; +1. The `center_h` value is applied to each element separately, meaning if you add two lines with the gravity value `center_h` in one line, they will not both be grouped and displayed in the center, but instead, they will split the screen in half and be displayed each in the center of its half. This situation can be rectified by using the `value anchor_prev` as the value for gravity. This flag anchors the current element to the previous element of the current line, so that the `gravity` value of the previous element starts affecting both elements. 2. The `right` value affects not only the element to which it is applied but also all subsequent elements in the current line. That means if you add another button after "Button #2", it will also be on the right side after "Button #2". Surely you will want to add icons to your UI. There are several ways to do this. The first way is to embed the icon directly into the text, in this case, you can use any icon from the FontAwesome set: @@ -65,14 +65,27 @@ The second way: use the icon command (in this case, you can also specify the siz {"icon", "fa:microphone", {size = 32, color = "#ff0000"}} ``` +Third way: display icon in the button: + +``` +{"button", "fa:microphone"} +{"button", "Text with icon: %%fa:microphone%%"} +``` + The second method also allows displaying icons of applications and contacts. How to do this is shown in the example [samples/rich-ui-sample.lua]. +By the way, if you want the button to stretch across the entire width of the screen, you can use the expand argument: + +``` +{"button", "Full with button", {expand = true}} +``` + Handling clicks on elements works the same as when using the `ui` module API. Just define `on_click()` or `on_long_click()` functions. The first parameter of the function will be the index of the element. How to use this mechanism can be learned in the example [samples/rich-ui-sample.lua]. This is all you need to know about the new API. Below is an example demonstrating all supported elements and all their default parameters: ``` -{"text", "", {size = 17, color = "", gravity = "left"}}, +{"text", "", {size = 17, color = "", gravity = "left", expand = false}}, {"button", "", {color = "", gravity = "left"}}, {"icon", "", {size = 17, color = "", gravity = "left"}}, {"progress" "", {progress = 0, color = "", gravity = "left"}}, -- 2.43.0 From 28e0e9baf59d074c898c9df427f6b5d9ac979794 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 27 Apr 2024 08:54:40 +0400 Subject: [PATCH 099/204] 1. Add new APIs to README and samples. 2. Added Birthdays widget --- README.md | 34 ++++++++++++-- community/birthdays-widget.lua | 86 ++++++++++++++++++++++++++++++++++ samples/folding-test2.lua | 9 ++++ samples/on_load_test.lua | 7 +++ 4 files changed, 132 insertions(+), 4 deletions(-) create mode 100644 community/birthdays-widget.lua create mode 100644 samples/folding-test2.lua create mode 100644 samples/on_load_test.lua diff --git a/README.md b/README.md index ce3e922..35f5145 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,11 @@ The type of script is determined by the line (meta tag) at the beginning of the # Changelog +### 5.2.3 + +* Added `on_load()` callback +* Added `on_resume_when_folding` meta tag + ### 5.2.1 * Added support for complex UIs @@ -38,17 +43,22 @@ The type of script is determined by the line (meta tag) at the beginning of the The work of the widget script begins with one of the three described functions. Main work should be done in one of them. +* `on_load()` - called on first script load (_starting with AIO Launcher 5.2.3_). * `on_resume()` - called every time you return to the desktop. * `on_alarm()` - called every time you return to the desktop, but no more than once every 30 minutes. * `on_tick(ticks)` - called every second while the launcher is on the screen. The `ticks` parameter is number of seconds after last return to the launcher. -The `on_resume()` and `on_alarm()` callbacks are also triggered when a widget is added to the screen and the screen is forced to refresh. +The `on_resume()` and `on_alarm()` callbacks are also triggered when a widget is added to the screen (if `on_load()` is not defined) and the screen is forced to refresh. For most network scripts `on_alarm()` should be used. # Search scripts -Unlike widget scripts, search scripts are launched only when you open the search window. Then the following function is triggered each time a character is entered: +Unlike widget scripts, search scripts are launched only when you open the search window: + +* `on_load()` - called every time when user opens the search window (_starting with AIO Launcher 5.2.3_). + +Then the following function is triggered each time a character is entered: * `on_search(string)` is run when each character is entered, `string` - entered string. @@ -117,8 +127,6 @@ _Available only in widget scripts._ * `ui:folding_flag()` - returns folding flag; * `ui:set_progress(float)` - sets current widget progress (like in Player and Health widgets). -When you click on any element of the interface, the `on_click(number)` callback will be executed, where number is the ordinal number of the element. A long click calls `on_long_click(number)`. For example, if you use `ui:show_buttons` to show three buttons, then clicking the first button will call `on_click` with argument 1, the second with arguments 2, and so on. If there is only one element on the screen, the argument will always be equal to one and can be omitted. - The `ui:show_chart()` function takes a string as its third argument to format the x and y values on the screen. For example, the string `x: date y: number` means that the X-axis values should be formatted as dates, and the Y-values should be formatted as a regular number. There are four formats in total: * `number` - an ordinary number with group separation; @@ -126,6 +134,22 @@ The `ui:show_chart()` function takes a string as its third argument to format th * `date` - date in day.month format; * `time` - time in hours:minutes format. +### Clicks + +When you click on any element of the interface, the `on_click(number)` callback will be executed, where number is the ordinal number of the element. A long click calls `on_long_click(number)`. For example, if you use `ui:show_buttons` to show three buttons, then clicking the first button will call `on_click` with argument 1, the second with arguments 2, and so on. If there is only one element on the screen, the argument will always be equal to one and can be omitted. + +### Folding + +By default, the script shows either the first line of content or a line specified in the function argument in collapsed mode. However, you can change this behavior using a special meta-tag: + +``` +-- on_resume_when_folding = "true" +``` + +In this case, the `on_resume()` callback will be triggered each time the widget is collapsed. Then you can check the widget's collapsed status using the `ui:folding_flag()` function and display different UI depending on the state of this flag. + +### HTML and Markdown formatting + The functions `ui:show_text()`, `ui:show_lines()` and `ui:show_table()` support many HTML tags. For example: ``` @@ -137,6 +161,8 @@ First line
Second line You can also use Markdown markup. To do this, add the prefix `%%mkd%%` to the beginning of the line. Or you can disable the formatting completely with the prefix `%%txt%%`. +### Icons + You can insert FontAwesome icons inside the text, to do this use this syntax: `%%fa:ICON_NAME%%. For example: ``` diff --git a/community/birthdays-widget.lua b/community/birthdays-widget.lua new file mode 100644 index 0000000..43cdb1a --- /dev/null +++ b/community/birthdays-widget.lua @@ -0,0 +1,86 @@ +-- name = "Birthdays" +-- name_id = "birthday" +-- description = "Shows upcoming birthdays from the contacts" +-- type = "widget" +-- author = "Andrey Gavrilov" +-- version = "1.0" + +local prefs = require "prefs" +local fmt = require "fmt" + +local months = { + "January", + "February", + "March", + "April", + "May", + "June", + "July", + "August", + "September", + "October", + "November", + "December" +} + +function on_resume() + if not prefs.count then + prefs.count = 10 + end + contacts = calendar:contacts_events() + redraw() +end + +function on_contacts_loaded() + redraw() +end + +function redraw() + table.sort(contacts,function(a,b) return a.begin < b.begin end) + events = {} + local lines = {} + for i,v in ipairs(contacts) do + table.insert(events, v) + table.insert(lines, fmt_line(v)) + if i == prefs.count then + break + end + end + ui:show_lines(lines) +end + +function fmt_line(event) + local line = event.title + if os.date("%y%m%d",event.begin) == os.date("%y%m%d") then + line = fmt.bold(fmt.colored(line, aio:colors().accent)) + end + return line .. fmt.secondary(" - ") .. fmt_date(event.begin) +end + +function fmt_date(date) + local d = "" + if os.date("%y%m%d",date) == os.date("%y%m%d") then + d = "Today" + elseif os.date("%y%m%d",date-86400) == os.date("%y%m%d") then + d = "Tomorrow" + else + d = months[tonumber(os.date("%m", date))] .. ", " .. tostring(tonumber(os.date("%d", date))) + end + return fmt.secondary(d) +end + +function on_click(idx) + calendar:show_event_dialog(events[idx]) +end + +function on_settings() + ui:show_radio_dialog("Number of events", {1,2,3,4,5,6,7,8,9,10}, prefs.count) +end + +function on_dialog_action(idx) + if idx == -1 then + return + end + prefs.count = idx + redraw() +end diff --git a/samples/folding-test2.lua b/samples/folding-test2.lua new file mode 100644 index 0000000..2038bcd --- /dev/null +++ b/samples/folding-test2.lua @@ -0,0 +1,9 @@ +-- on_resume_when_folding = "true" + +local counter = 0 + +function on_resume() + counter = counter+1 + ui:show_text("refresh times: "..counter) + ui:show_toast("on_resume called") +end diff --git a/samples/on_load_test.lua b/samples/on_load_test.lua new file mode 100644 index 0000000..878971c --- /dev/null +++ b/samples/on_load_test.lua @@ -0,0 +1,7 @@ +function on_load() + ui:show_text("Script loaded") +end + +function on_resume() + ui:show_text("Script resumed") +end -- 2.43.0 From eb118bf32a2ad2042918f3f28486223c7af887a2 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 28 Apr 2024 21:07:43 +0400 Subject: [PATCH 100/204] Move useless scripts to samples --- community/bdpn-search.lua | 42 +- community/sudoku-widget.lua | 2 +- {community => samples}/currencies-widget.lua | 0 {community => samples}/currency-search.lua | 0 {community => samples}/currency-widget-ru.lua | 390 +++++++++--------- .../tasker-widget-control.lua | 0 6 files changed, 218 insertions(+), 216 deletions(-) rename {community => samples}/currencies-widget.lua (100%) rename {community => samples}/currency-search.lua (100%) rename {community => samples}/currency-widget-ru.lua (97%) rename {community => samples}/tasker-widget-control.lua (100%) diff --git a/community/bdpn-search.lua b/community/bdpn-search.lua index 1ce7ce1..7286413 100644 --- a/community/bdpn-search.lua +++ b/community/bdpn-search.lua @@ -4,38 +4,40 @@ -- type = "search" -- lang = "ru" -- author = "Andrey Gavrilov" --- version = "1.0" - -local num = "" +-- version = "1.1" function on_search(input) - num = input:match("^n (.+)") + local num = input:match("^(+?7?%d%d%d%d%d%d%d%d%d%d+)$") if not num then return end - search:show({"Оператор "..num}) + show_operator(num) end -function on_click() +function show_operator(num) + local json = require "json" local uri = "http://rosreestr.subnets.ru/?get=num&format=json&num=" .. num:gsub("%D", "") - http:get(uri) - return false -end - -function on_network_result(result) - local json = require "json" - local t = json.decode(result) - if not t.error then - if not t["0"].country then - if not t["0"].moved2operator then - search:show({t["0"].operator, t["0"].region}) + local tab = {} + local result = shttp:get(uri) + if not result.error then + local t = json.decode(result.body) + if not t.error then + if not t["0"].country then + if not t["0"].moved2operator then + table.insert(tab, t["0"].operator) + else + table.insert(tab, t["0"].moved2operator) + end + table.insert(tab, t["0"].region) else - search:show({t["0"].moved2operator, t["0"].region}) + table.insert(tab, t["0"].country) + table.insert(tab, t["0"].description) end else - search:show({t["0"].country, t["0"].description}) + table.insert(tab, t.error) end else - search:show({t.error}) + table.insert(tab, result.error) end + search:show_lines({table.concat(tab, ", ")}, {aio:colors().button}) end diff --git a/community/sudoku-widget.lua b/community/sudoku-widget.lua index 96bb643..a8ded2a 100644 --- a/community/sudoku-widget.lua +++ b/community/sudoku-widget.lua @@ -1,6 +1,6 @@ -- name = "Sudoku" -- description = "Sudoku games" --- type = "Game" +-- type = "widget" -- author = "Andrey Gavrilov" -- version = "1.0" diff --git a/community/currencies-widget.lua b/samples/currencies-widget.lua similarity index 100% rename from community/currencies-widget.lua rename to samples/currencies-widget.lua diff --git a/community/currency-search.lua b/samples/currency-search.lua similarity index 100% rename from community/currency-search.lua rename to samples/currency-search.lua diff --git a/community/currency-widget-ru.lua b/samples/currency-widget-ru.lua similarity index 97% rename from community/currency-widget-ru.lua rename to samples/currency-widget-ru.lua index 78466a0..93215e3 100644 --- a/community/currency-widget-ru.lua +++ b/samples/currency-widget-ru.lua @@ -1,195 +1,195 @@ --- name = "Курс валюты" --- description = "Виджет курса валюты. Нажмите на виджет, чтобы изменить валюту. Базовая валюта и дата меняются в контекстном меню." --- data_source = "https://exchangerate.host/" --- type = "widget" --- author = "Andrey Gavrilov" --- version = "2.0" --- lang = "ru" - -local json = require "json" -local color = require "md_colors" -local text_color = ui:get_colors().secondary_text -local equals = " = " - --- константы -- -local curs = {"usd", "eur", "gbp", "chf", "aed", "cny", "inr", "btc", "other"} -local curs_n = {"Доллар США", "Евро", "Фунт стерлингов", "Швейцарский франк", "Дирхам ОАЭ", "Китайский юань", "Индийская рупия", "Биткойн", "Другая"} -local base_curs = {"rub", "usd", "other_b"} -local base_curs_n = {"Российский рубль", "Доллар США", "Другая"} - --- переменные -- -local dialog_id = "" -local cur_idx = 1 -local cur = curs[cur_idx] -local base_cur_idx = 1 -local base_cur = base_curs[base_cur_idx] -local date = "" -local line = "" -local tab = {} -local amount = "1" -local rate = 0 - -function on_alarm() - date = os.date("%Y-%m-%d") - get_rates(date) -end - -function get_rates(date) - http:get("https://api.exchangerate.host/fluctuation?start_date="..prev_date(date).."&end_date="..date.."&symbols="..string.upper(base_cur).."&base="..string.upper(cur).."&amount="..amount) -end - -function on_network_result(result) - t = json.decode(result) - if t.rates[string.upper(base_cur)].end_rate == nil then - date = prev_date(date) - get_rates(date) - return - end - rate = round(t.rates[string.upper(base_cur)].end_rate,4) - local change = round(-t.rates[string.upper(base_cur)].change_pct*100,2) - line = amount.." "..string.upper(cur).." "..equals.." "..divide_number(rate," ").." "..string.upper(base_cur)..get_formatted_change_text(change) - tab = {{"ᐊ", amount, string.upper(cur), equals, divide_number(rate," "), string.upper(base_cur), get_formatted_change_text(change), "ᐅ"}} - ui:show_table(tab, 7) - ui:set_title(ui:get_default_title().." ("..date:gsub("(%d+)-(%d+)-(%d+)", "%3.%2.%1")..")") -end - -function on_click(idx) - if idx == 1 then - date = prev_date(date) - get_rates(date) - ui:show_toast("Загрузка") - elseif idx == 2 then - dialog_id ="amount" - ui:show_edit_dialog("Введите количество", "", amount) - elseif idx == 3 then - dialog_id = "cur" - ui:show_radio_dialog("Выберите валюту", curs_n, cur_idx) - elseif idx == 6 then - dialog_id = "base_cur" - ui:show_radio_dialog("Выберите базовую валюту", base_curs_n, base_cur_idx) - elseif idx == 8 then - date = next_date(date) - get_rates(date) - ui:show_toast("Загрузка") - else - dialog_id = "date" - ui:show_edit_dialog("Введите дату курса", "Формат даты - 31.12.2020. Пустое значение - текущая дата", date:gsub("(%d+)-(%d+)-(%d+)", "%3.%2.%1")) - end -end - -function on_long_click(idx) - item_idx = idx - - ui:show_context_menu({ - {"share-alt","Поделиться"}, - {"copy","Копировать"}, - {"redo","Перезагрузить"} - }) -end - -function on_dialog_action(data) - if data == -1 then - return - end - if dialog_id == "date" then - if get_date(date:gsub("(%d+)-(%d+)-(%d+)", "%3.%2.%1")) == get_date(data) then - return - end - date = get_date(data) - elseif dialog_id == "cur" then - if data == cur_idx and cur == curs[data] then - return - end - cur_idx = data - if curs[data] == "other" then - dialog_id = "other" - ui:show_edit_dialog("Введите валюту", "", string.lower(cur)) - return - end - cur = string.upper(curs[data]) - elseif dialog_id == "base_cur" then - if data == base_cur_idx and base_cur == base_curs[data] then - return - end - base_cur_idx = data - if base_curs[data] == "other_b" then - dialog_id = "other_b" - ui:show_edit_dialog("Введите базовую валюту", "", string.lower(base_cur)) - return - end - base_cur = string.upper(base_curs[data]) - elseif dialog_id == "other" then - if data == cur then - return - end - cur = string.upper(data) - elseif dialog_id == "other_b" then - if data == base_cur then - return - end - base_cur = string.upper(data) - elseif dialog_id == "amount" then - if amount == data:gsub(",",".") then - return - end - amount = data:gsub(",","."):gsub("-","") - if amount == "" then - amount = "1" - end - end - get_rates(date) -end - -function on_context_menu_click(menu_idx) - if menu_idx == 2 then - system:copy_to_clipboard(rate) - elseif menu_idx == 1 then - system:share_text(date:gsub("(%d+)-(%d+)-(%d+)", "%3.%2.%1").." "..line:gsub("(.+)<.+>(.+)<.+>(.+)<.+>(.+)<.+>", "%1%2%3%4")) - elseif menu_idx == 3 then - cur_idx = 1 - cur = string.upper(curs[cur_idx]) - base_cur_idx = 1 - base_cur = string.upper(base_curs[base_cur_idx]) - amount = "1" - get_rates(os.date("%Y-%m-%d")) - ui:show_toast("Начальные установки") - end -end - --- утилиты -- -function get_formatted_change_text(change) - if change > 0 then - return " +"..change.."%" - elseif change < 0 then - return " "..change.."%" - else - return " "..change.."%" - end -end - -function prev_date(date) - local y, m, d = date:match("(%d+)-(%d+)-(%d+)") - return os.date("%Y-%m-%d", os.time{year=y, month=m, day=d} - (60*60*24)) -end - -function next_date(date) - local y, m, d = date:match("(%d+)-(%d+)-(%d+)") - return os.date("%Y-%m-%d", os.time{year=y, month=m, day=d} + (60*60*24)) -end - -function divide_number(n, str) - local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$') - return left..(num:reverse():gsub('(%d%d%d)','%1'..str):reverse())..right -end - -function get_date(date) - local d, m, Y = date:match("(%d+).(%d+).(%d+)") - local d0, m0, Y0 = os.date("%d.%m.%Y"):match("(%d+).(%d+).(%d+)") - local time = os.time{day=d or 0, month=m or 0, year=Y or 0} - local time0 = os.time{day=d0, month=m0, year=Y0} - local str = string.format("%04d-%02d-%02d", Y or 0, m or 0, d or 0) - if not (str == os.date("%Y-%m-%d", time) and time <= time0 - 24*60*60) then - str = os.date("%Y-%m-%d") - end - return str -end +-- name = "Курс валюты" +-- description = "Виджет курса валюты. Нажмите на виджет, чтобы изменить валюту. Базовая валюта и дата меняются в контекстном меню." +-- data_source = "https://exchangerate.host/" +-- type = "widget" +-- author = "Andrey Gavrilov" +-- version = "2.0" +-- lang = "ru" + +local json = require "json" +local color = require "md_colors" +local text_color = ui:get_colors().secondary_text +local equals = " = " + +-- константы -- +local curs = {"usd", "eur", "gbp", "chf", "aed", "cny", "inr", "btc", "other"} +local curs_n = {"Доллар США", "Евро", "Фунт стерлингов", "Швейцарский франк", "Дирхам ОАЭ", "Китайский юань", "Индийская рупия", "Биткойн", "Другая"} +local base_curs = {"rub", "usd", "other_b"} +local base_curs_n = {"Российский рубль", "Доллар США", "Другая"} + +-- переменные -- +local dialog_id = "" +local cur_idx = 1 +local cur = curs[cur_idx] +local base_cur_idx = 1 +local base_cur = base_curs[base_cur_idx] +local date = "" +local line = "" +local tab = {} +local amount = "1" +local rate = 0 + +function on_alarm() + date = os.date("%Y-%m-%d") + get_rates(date) +end + +function get_rates(date) + http:get("https://api.exchangerate.host/fluctuation?start_date="..prev_date(date).."&end_date="..date.."&symbols="..string.upper(base_cur).."&base="..string.upper(cur).."&amount="..amount) +end + +function on_network_result(result) + t = json.decode(result) + if t.rates[string.upper(base_cur)].end_rate == nil then + date = prev_date(date) + get_rates(date) + return + end + rate = round(t.rates[string.upper(base_cur)].end_rate,4) + local change = round(-t.rates[string.upper(base_cur)].change_pct*100,2) + line = amount.." "..string.upper(cur).." "..equals.." "..divide_number(rate," ").." "..string.upper(base_cur)..get_formatted_change_text(change) + tab = {{"ᐊ", amount, string.upper(cur), equals, divide_number(rate," "), string.upper(base_cur), get_formatted_change_text(change), "ᐅ"}} + ui:show_table(tab, 7) + ui:set_title(ui:get_default_title().." ("..date:gsub("(%d+)-(%d+)-(%d+)", "%3.%2.%1")..")") +end + +function on_click(idx) + if idx == 1 then + date = prev_date(date) + get_rates(date) + ui:show_toast("Загрузка") + elseif idx == 2 then + dialog_id ="amount" + ui:show_edit_dialog("Введите количество", "", amount) + elseif idx == 3 then + dialog_id = "cur" + ui:show_radio_dialog("Выберите валюту", curs_n, cur_idx) + elseif idx == 6 then + dialog_id = "base_cur" + ui:show_radio_dialog("Выберите базовую валюту", base_curs_n, base_cur_idx) + elseif idx == 8 then + date = next_date(date) + get_rates(date) + ui:show_toast("Загрузка") + else + dialog_id = "date" + ui:show_edit_dialog("Введите дату курса", "Формат даты - 31.12.2020. Пустое значение - текущая дата", date:gsub("(%d+)-(%d+)-(%d+)", "%3.%2.%1")) + end +end + +function on_long_click(idx) + item_idx = idx + + ui:show_context_menu({ + {"share-alt","Поделиться"}, + {"copy","Копировать"}, + {"redo","Перезагрузить"} + }) +end + +function on_dialog_action(data) + if data == -1 then + return + end + if dialog_id == "date" then + if get_date(date:gsub("(%d+)-(%d+)-(%d+)", "%3.%2.%1")) == get_date(data) then + return + end + date = get_date(data) + elseif dialog_id == "cur" then + if data == cur_idx and cur == curs[data] then + return + end + cur_idx = data + if curs[data] == "other" then + dialog_id = "other" + ui:show_edit_dialog("Введите валюту", "", string.lower(cur)) + return + end + cur = string.upper(curs[data]) + elseif dialog_id == "base_cur" then + if data == base_cur_idx and base_cur == base_curs[data] then + return + end + base_cur_idx = data + if base_curs[data] == "other_b" then + dialog_id = "other_b" + ui:show_edit_dialog("Введите базовую валюту", "", string.lower(base_cur)) + return + end + base_cur = string.upper(base_curs[data]) + elseif dialog_id == "other" then + if data == cur then + return + end + cur = string.upper(data) + elseif dialog_id == "other_b" then + if data == base_cur then + return + end + base_cur = string.upper(data) + elseif dialog_id == "amount" then + if amount == data:gsub(",",".") then + return + end + amount = data:gsub(",","."):gsub("-","") + if amount == "" then + amount = "1" + end + end + get_rates(date) +end + +function on_context_menu_click(menu_idx) + if menu_idx == 2 then + system:copy_to_clipboard(rate) + elseif menu_idx == 1 then + system:share_text(date:gsub("(%d+)-(%d+)-(%d+)", "%3.%2.%1").." "..line:gsub("(.+)<.+>(.+)<.+>(.+)<.+>(.+)<.+>", "%1%2%3%4")) + elseif menu_idx == 3 then + cur_idx = 1 + cur = string.upper(curs[cur_idx]) + base_cur_idx = 1 + base_cur = string.upper(base_curs[base_cur_idx]) + amount = "1" + get_rates(os.date("%Y-%m-%d")) + ui:show_toast("Начальные установки") + end +end + +-- утилиты -- +function get_formatted_change_text(change) + if change > 0 then + return " +"..change.."%" + elseif change < 0 then + return " "..change.."%" + else + return " "..change.."%" + end +end + +function prev_date(date) + local y, m, d = date:match("(%d+)-(%d+)-(%d+)") + return os.date("%Y-%m-%d", os.time{year=y, month=m, day=d} - (60*60*24)) +end + +function next_date(date) + local y, m, d = date:match("(%d+)-(%d+)-(%d+)") + return os.date("%Y-%m-%d", os.time{year=y, month=m, day=d} + (60*60*24)) +end + +function divide_number(n, str) + local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$') + return left..(num:reverse():gsub('(%d%d%d)','%1'..str):reverse())..right +end + +function get_date(date) + local d, m, Y = date:match("(%d+).(%d+).(%d+)") + local d0, m0, Y0 = os.date("%d.%m.%Y"):match("(%d+).(%d+).(%d+)") + local time = os.time{day=d or 0, month=m or 0, year=Y or 0} + local time0 = os.time{day=d0, month=m0, year=Y0} + local str = string.format("%04d-%02d-%02d", Y or 0, m or 0, d or 0) + if not (str == os.date("%Y-%m-%d", time) and time <= time0 - 24*60*60) then + str = os.date("%Y-%m-%d") + end + return str +end diff --git a/community/tasker-widget-control.lua b/samples/tasker-widget-control.lua similarity index 100% rename from community/tasker-widget-control.lua rename to samples/tasker-widget-control.lua -- 2.43.0 From 71793eb3d3b5408a1dedcad56da565752ed919f2 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 30 Apr 2024 12:22:16 +0400 Subject: [PATCH 101/204] Fix sunrise/sunset widget --- main/sunrise-sunset-widget.lua | 41 +++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/main/sunrise-sunset-widget.lua b/main/sunrise-sunset-widget.lua index 95a5667..b7a3fa9 100644 --- a/main/sunrise-sunset-widget.lua +++ b/main/sunrise-sunset-widget.lua @@ -3,26 +3,24 @@ -- data_source = "https://api.sunrise-sunset.org/" -- type = "widget" -- author = "Sriram S V" --- version = "1.0" +-- version = "1.1" -- foldable = "false" local json = require "json" -local date = require "date" local fmt = require "fmt" function on_alarm() local location=system:location() - local url="https://api.sunrise-sunset.org/json?lat="..location[1].."&lng="..location[2].."&date=today&formatted=1" + local url="https://api.sunrise-sunset.org/json?lat="..location[1].."&lng="..location[2].."&formatted=0" http:get(url) end - function on_network_result(result) local t = json.decode(result) - local sunrise_time = date(t.results.sunrise):tolocal():fmt("%H:%M") - local sunset_time = date(t.results.sunset):tolocal():fmt("%H:%M") + local sunrise_time = utc_to_local(parse_iso8601_datetime(t.results.sunrise)) + local sunset_time = utc_to_local(parse_iso8601_datetime(t.results.sunset)) ui:show_text( aio:res_string("today", "Today")..":".. @@ -30,3 +28,34 @@ function on_network_result(result) fmt.space(4).."⬇"..fmt.space(2)..sunset_time ) end + +function parse_iso8601_datetime(json_date) + local pattern = "(%d+)%-(%d+)%-(%d+)%a(%d+)%:(%d+)%:([%d%.]+)([Z%+%-]?)(%d?%d?)%:?(%d?%d?)" + local year, month, day, hour, minute, + seconds, offsetsign, offsethour, offsetmin = json_date:match(pattern) + local timestamp = os.time{year = year, month = month, + day = day, hour = hour, min = minute, sec = seconds} + local offset = 0 + if offsetsign ~= '' and offsetsign ~= 'Z' then + offset = tonumber(offsethour) * 60 + tonumber(offsetmin) + if xoffset == "-" then offset = offset * -1 end + end + + return timestamp + offset * 60 +end + +function utc_to_local(utctime) + local local_time_str = os.date("%H:%M", utctime) + local utc_time_str = os.date("!%H:%M", utctime) + + local function time_to_seconds(timestr) + local hour, minute = timestr:match("(%d+):(%d+)") + return tonumber(hour) * 3600 + tonumber(minute) * 60 + end + + local local_seconds = time_to_seconds(local_time_str) + local utc_seconds = time_to_seconds(utc_time_str) + local delta = local_seconds - utc_seconds + + return os.date("%H:%M", utctime + delta) +end -- 2.43.0 From 721413cd52345a52cf5aab442c64b99fc061eeec Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 30 Apr 2024 12:30:44 +0400 Subject: [PATCH 102/204] Add Solar Cycle and Uptimerobot 2 widgets --- community/solar-cycle-widget.lua | 79 ++++++++++++++++++++++++++++++ community/uptimerobot-2-widget.lua | 69 ++++++++++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 community/solar-cycle-widget.lua create mode 100644 community/uptimerobot-2-widget.lua diff --git a/community/solar-cycle-widget.lua b/community/solar-cycle-widget.lua new file mode 100644 index 0000000..1cbb017 --- /dev/null +++ b/community/solar-cycle-widget.lua @@ -0,0 +1,79 @@ +-- name = "Solar Cycle" +-- description = "Shows Sunrise Sunset at your location" +-- data_source = "https://api.sunrise-sunset.org/" +-- type = "widget" +-- author = "Sriram S V, Will Hall" +-- version = "1.0" +-- foldable = "false" + +local json = require "json" +local md_colors = require "md_colors" + +function on_alarm() + local location=system:location() + url="https://api.sunrise-sunset.org/json?lat="..location[1].."&lng="..location[2].."&formatted=0" + http:get(url) +end + + +function on_network_result(result) + local t = json.decode(result) + + local times_table = { + { + gen_icon("red_900","↦"), + gen_icon("orange_900", "↗"), + gen_icon("yellow_900", "☀"), + gen_icon("orange_900", "↘"), + gen_icon("red_900", "⇥"), + }, + { + time_from_utc(t.results.civil_twilight_begin), + time_from_utc(t.results.sunrise), + time_from_utc(t.results.solar_noon), + time_from_utc(t.results.sunset), + time_from_utc(t.results.civil_twilight_end), + } + } + + ui:show_table(times_table, 0, true) +end + +function time_from_utc(utc) + return utc_to_local(parse_iso8601_datetime(utc)) +end + +function gen_icon(md_color, icon) + return ""..icon.."" +end + +function parse_iso8601_datetime(json_date) + local pattern = "(%d+)%-(%d+)%-(%d+)%a(%d+)%:(%d+)%:([%d%.]+)([Z%+%-]?)(%d?%d?)%:?(%d?%d?)" + local year, month, day, hour, minute, + seconds, offsetsign, offsethour, offsetmin = json_date:match(pattern) + local timestamp = os.time{year = year, month = month, + day = day, hour = hour, min = minute, sec = seconds} + local offset = 0 + if offsetsign ~= '' and offsetsign ~= 'Z' then + offset = tonumber(offsethour) * 60 + tonumber(offsetmin) + if xoffset == "-" then offset = offset * -1 end + end + + return timestamp + offset * 60 +end + +function utc_to_local(utctime) + local local_time_str = os.date("%H:%M", utctime) + local utc_time_str = os.date("!%H:%M", utctime) + + local function time_to_seconds(timestr) + local hour, minute = timestr:match("(%d+):(%d+)") + return tonumber(hour) * 3600 + tonumber(minute) * 60 + end + + local local_seconds = time_to_seconds(local_time_str) + local utc_seconds = time_to_seconds(utc_time_str) + local delta = local_seconds - utc_seconds + + return os.date("%H:%M", utctime + delta) +end diff --git a/community/uptimerobot-2-widget.lua b/community/uptimerobot-2-widget.lua new file mode 100644 index 0000000..722d528 --- /dev/null +++ b/community/uptimerobot-2-widget.lua @@ -0,0 +1,69 @@ +-- name = "Uptimerobot V2" +-- description = "Shows uptime information from uptimerobot.com. Needs API key. Button-based Version." +-- data_source = "uptimerobot.com" +-- type = "widget" +-- author = "Evgeny Zobnin (zobnin@gmail.com), Will Hall (hello@willhall.uk)" +-- version = "1.0" +-- arguments_help = "Enter your API key" + +local json = require "json" +local md_colors = require "md_colors" + +-- constants +local api_url = "https://api.uptimerobot.com/v2/" +local base_click_url = "https://uptimerobot.com/dashboard#" +local media_type = "application/x-www-form-urlencoded" +local status_colors = { "grey_500", "green_500", "red_500", "red_500", "red_500", "red_500", "red_500", "orange_500", "red_500" } + +-- monitors +local monitor_ids = {} + +function on_alarm() + if (next(settings:get()) == nil) then + ui:show_text("Tap to enter API key") + return + end + + local key = settings:get()[1] + local body = "api_key="..key.."&format=json" + + http:post(api_url.."getMonitors", body, media_type) +end + +function on_click(i) + if (next(settings:get()) == nil) then + settings:show_dialog() + else + if(monitor_ids[i] ~= nil) then + system:open_browser(base_click_url..monitor_ids[i]) + else + system:open_browser(base_click_url.."mainDashboard") + end + end +end + +function on_network_result(result, code) + if (code >= 400) then + ui:show_text("Error: "..code) + return + end + + local parsed = json.decode(result) + + if (parsed.stat ~= "ok") then + ui:show_text("Error: "..parsed.error.message) + return + end + + local names = {} + local colours = {} + + for k,v in pairs(parsed.monitors) do + monitor_ids[k] = v.id + names[k] = v.friendly_name + colours[k] = md_colors[status_colors[v.status]] or md_colors["grey_500"] + end + + ui:show_buttons(names, colours) + +end \ No newline at end of file -- 2.43.0 From 9e88620428abd66c238ed96021806f8c595b29ef Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 30 Apr 2024 12:56:25 +0400 Subject: [PATCH 103/204] Update scripts zip --- scripts.md5 | 2 +- scripts.zip | Bin 18640 -> 18998 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts.md5 b/scripts.md5 index d57d46e..a97470e 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -a262726ee83c9e9f7e45a994c01d4fc1 +4a21417c17c94f75078574e11a1e9d71 diff --git a/scripts.zip b/scripts.zip index 1a273addec10597e955c0b2f641e6198f9a04ad4..0a5b2d8705433fd11d35ee4927b507e155a05abd 100644 GIT binary patch delta 1125 zcmcaGk#XA;#tD|p{?iOL+8ksA(VLj+I6?I0M($cBFoThAGK4W*pbxBMvxd-22;+$G z3g@TMiPwZ-r zDtKHd@V(2zKItz0c38gY>7=sKRXR3-Z1cEw#!GR? zSU;|gpI$wE-nRmQODWT~F45ho_P*z#@#Is5QOmOzuW|{#wEI}gij2h(2D3B0cz-VF zS)MZgSCo-ZhGoIFRjl`0ln$+$C%!D@VDYVhn{FR_9-Mb-v)cY@MZ?zmn+pDOs&3}| z58e7~W41<4vx#ieoi+KFO)Bnv`0G-gx@GDFUDkxBWvx1;M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arIj|e7ty~zz8F-)2Ilka&% uF+H`OY~>lnq;5BPnr9UAU3-Sf36A2EH+V{ju(B}#fd~+O2eJ-3f_MPwxIM`L -- 2.43.0 From 4f4a82993c640cc4f85468200df95134584dd529 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 2 May 2024 17:07:15 +0400 Subject: [PATCH 104/204] Update google translate widget --- community/google-translate-widget.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/community/google-translate-widget.lua b/community/google-translate-widget.lua index 841c4a7..038f2ad 100644 --- a/community/google-translate-widget.lua +++ b/community/google-translate-widget.lua @@ -2,7 +2,7 @@ -- data_source = "https://translate.google.com" -- type = "widget" -- author = "Andrey Gavrilov" --- version = "1.1" +-- version = "1.2" local json = require "json" local uri = "http://translate.googleapis.com/translate_a/single?client=gtx&sl=auto" @@ -18,7 +18,7 @@ end function on_dialog_action(text) if text == "" or text == -1 then - on_alarm() + on_resume() else text_from = text translate(text) -- 2.43.0 From 029781b7c22543c4c2708982bb91f46c3afd402c Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 5 May 2024 16:25:27 +0400 Subject: [PATCH 105/204] Update README: add links --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 35f5145..4518531 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,13 @@ The type of script is determined by the line (meta tag) at the beginning of the *Read more about meta tags at the end of the document.* +# Links + +* [AIO Scripting Telegram Group](https://t.me/aio_scripting) +* [AIO Script Store app](https://play.google.com/store/apps/details?id=ru.execbit.aiostore) +* [Lua Guide](https://www.lua.org/pil/contents.html) +* [Many Lua samples](http://lua-users.org/wiki/SampleCode) + # Changelog ### 5.2.3 -- 2.43.0 From f90e811498992e6e754dde23e0e44cde951a60b2 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 5 May 2024 16:25:47 +0400 Subject: [PATCH 106/204] Update Birthdays widget --- community/birthdays-widget.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/community/birthdays-widget.lua b/community/birthdays-widget.lua index 43cdb1a..7dc90ea 100644 --- a/community/birthdays-widget.lua +++ b/community/birthdays-widget.lua @@ -3,7 +3,7 @@ -- description = "Shows upcoming birthdays from the contacts" -- type = "widget" -- author = "Andrey Gavrilov" --- version = "1.0" +-- version = "1.1" local prefs = require "prefs" local fmt = require "fmt" @@ -27,6 +27,10 @@ function on_resume() if not prefs.count then prefs.count = 10 end + phone:request_permission() +end + +function on_permission_granted() contacts = calendar:contacts_events() redraw() end -- 2.43.0 From 36f4e4856bd3fcef0736591e7e508f14794a4fc5 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 5 May 2024 18:32:01 +0400 Subject: [PATCH 107/204] Add Amdroid Buttons widget --- community/amdroid-buttons-app-widget.lua | 90 ++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 community/amdroid-buttons-app-widget.lua diff --git a/community/amdroid-buttons-app-widget.lua b/community/amdroid-buttons-app-widget.lua new file mode 100644 index 0000000..055df52 --- /dev/null +++ b/community/amdroid-buttons-app-widget.lua @@ -0,0 +1,90 @@ +-- name = "Amdroid Buttons" +-- description = "Foldable AIO wrapper for the Amdroid next alarm app widget" +-- type = "widget" +-- author = "Theodor Galanis" +-- version = "1.05" +-- foldable = "true" +-- on_resume_when_folding = "true" +-- uses_app = "com.amdroidalarmclock.amdroid" + + +local prefs = require "prefs" +local indices = {1, 3, 4, 6, 8} +local next_alarm = "" +local accent="#888888" +local temp = {} + +function on_resume() + if not widgets:bound(prefs.wid) then + setup_app_widget() + end + accent = aio:colors().accent + primary = aio:colors().primary_text + widgets:request_updates(prefs.wid) +end + +function on_app_widget_updated(bridge) + local tab = bridge:dump_table() +next_alarm = tab.frame_layout_1.v_layout_1.text_1 + w_bridge = bridge + local state = ui:folding_flag() + if state == false then +temp = { + {"icon", "fa:alarm-clock", {gravity="center_h|center_v",color = accent}}, + {"spacer", 2 }, + {"text", next_alarm, {gravity="anchor_prev"}}, + {"button", "fa:backward", {gravity = "right"}}, + {"spacer", 2}, + {"button", "fa:right-long-to-line"}, + {"spacer", 2}, + {"button", "fa:forward"} + } + else + temp = { + {"icon", "fa:alarm-clock", {gravity="center_h|center_v",color = accent}}, + {"spacer", 2 }, + {"text", next_alarm, {gravity="anchor_prev"}} + } + end + + my_gui = gui(temp) + my_gui.render() +end + +function on_click(idx) +if idx == indices[1] or idx == indices[2] then + w_bridge:click(next_alarm) + elseif idx == indices[3] then + w_bridge:click("image_3") + elseif idx == indices[4] then + w_bridge:click("image_1") + elseif idx == indices[5] then + w_bridge:click("image_2") + end +end + +function on_long_click(idx) +if idx == indices[1] or idx == indices[2] then + ui:show_toast("Open Amdroid app") + elseif idx == indices[3] then + ui:show_toast("Adjust alarm's next occurance time 10 minutes earlier") + elseif idx == indices[4] then +ui:show_toast("Skip alarm's next occurance") + elseif idx == indices[5] then + ui:show_toast("Adjust alarm's next occurance time 10 minutes later") + end +end + +function on_settings() +ui:show_dialog("Amdroid app Buttons widget", "This script wrapper uses Amdroid app's Buttons widget. No settings are required.") +end + +function setup_app_widget() + local id = widgets:setup("com.amdroidalarmclock.amdroid/com.amdroidalarmclock.amdroid.AmdroidAppWidgetProvider") + + if (id ~= nil) then + prefs.wid = id + else + ui:show_text("Can't add widget") + end +end \ No newline at end of file -- 2.43.0 From bcf5484f49fb1d7297769c4a5bb7fe6661b0e972 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 6 May 2024 12:29:43 +0400 Subject: [PATCH 108/204] Update Amdroid Buttons widget --- community/amdroid-buttons-app-widget.lua | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/community/amdroid-buttons-app-widget.lua b/community/amdroid-buttons-app-widget.lua index 055df52..5103e69 100644 --- a/community/amdroid-buttons-app-widget.lua +++ b/community/amdroid-buttons-app-widget.lua @@ -1,13 +1,12 @@ -- name = "Amdroid Buttons" --- description = "Foldable AIO wrapper for the Amdroid next alarm app widget" +-- description = "Foldable AIO wrapper for the Amdroid Buttons app widget" -- type = "widget" --- author = "Theodor Galanis" --- version = "1.05" +-- author = "Theodor Galanis (t.me/TheodorGalanis)" +-- version = "1.10" -- foldable = "true" -- on_resume_when_folding = "true" -- uses_app = "com.amdroidalarmclock.amdroid" - local prefs = require "prefs" local indices = {1, 3, 4, 6, 8} local next_alarm = "" @@ -19,7 +18,6 @@ function on_resume() setup_app_widget() end accent = aio:colors().accent - primary = aio:colors().primary_text widgets:request_updates(prefs.wid) end @@ -76,7 +74,7 @@ ui:show_toast("Skip alarm's next occurance") end function on_settings() -ui:show_dialog("Amdroid app Buttons widget", "This script wrapper uses Amdroid app's Buttons widget. No settings are required.") +ui:show_dialog("Amdroid app Buttons widget", "This script wrapper uses Amdroid app's Buttons widget. Long click each button for function description. No settings are required.") end function setup_app_widget() -- 2.43.0 From 969c13fba100b26295440ad3a068c0f454152978 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 6 May 2024 12:30:05 +0400 Subject: [PATCH 109/204] Fixes in samples --- samples/jepardy-widget.lua | 2 +- samples/settings-test.lua | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-) delete mode 100644 samples/settings-test.lua diff --git a/samples/jepardy-widget.lua b/samples/jepardy-widget.lua index 33c0807..bd686ef 100644 --- a/samples/jepardy-widget.lua +++ b/samples/jepardy-widget.lua @@ -1,6 +1,6 @@ --[[ -This script is getnerated by ChatGPT +This script is generated by ChatGPT Prompt:Search the internet for examples of scripts for AIO Launcher and write a script named "Jepardy" that will display a question from its database of questions with three answer options on the screen. If the answer is correct, a toast "Correct!" should appear on the screen, and a new question should be displayed. If the answer is incorrect, display a toast "Not correct" and present a new question. The database should contain questions in English. diff --git a/samples/settings-test.lua b/samples/settings-test.lua deleted file mode 100644 index 17b9780..0000000 --- a/samples/settings-test.lua +++ /dev/null @@ -1,13 +0,0 @@ -function on_resume() - local s1 = { - key1 = "123", - key2 = "val ue 2", - } - - settings:set_kv(s1) - - local s2 = settings:get_kv() - - ui:show_text("key1=\""..s2.key1.."\" ".."key2=\""..s2.key2.."\"") -end - -- 2.43.0 From b83fb1e1bb2cf44bbc384fd6bf2d4f90a3b8ac4c Mon Sep 17 00:00:00 2001 From: Hannu Hartikainen Date: Mon, 6 May 2024 09:38:29 +0300 Subject: [PATCH 110/204] Add Electricity spot price widget This widget supports showing electricity spot price for many areas in Europe. However, there's no configuration UI yet. I'm hoping there will be native support for editing the values in `prefs` later, but I'm also open to implementing the configuration UI in the widget if I get some help. The chart would be better if displayed with timestamps, but that doesn't currently work when the timestamps span two days. --- community/electricity-price-widget.lua | 183 +++++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 community/electricity-price-widget.lua diff --git a/community/electricity-price-widget.lua b/community/electricity-price-widget.lua new file mode 100644 index 0000000..a3f3c83 --- /dev/null +++ b/community/electricity-price-widget.lua @@ -0,0 +1,183 @@ +-- name = "Electricity spot price" +-- description = "Day-ahead spot price of electricity" +-- data_source = "https://api.energy-charts.info/" +-- type = "widget" +-- foldable = "true" +-- author = "Hannu Hartikainen " +-- version = "1.0" + +json = require "json" +prefs = require "prefs" + +url_base = "https://api.energy-charts.info/price?bzn=%s&end=%d" + +price_data = nil +price_interval = nil +price_unit = nil +unit_multiplier = 1 + +next_fetch_ts = 0 +next_redraw_ts = nil + +-- parameters and default values +function on_load() + -- bidding zone: see "Available bidding zones" in https://api.energy-charts.info/ + if not prefs.bidding_zone then + prefs.bidding_zone = "FI" + end + + -- VAT percentage + if not prefs.vat_percentage then + prefs.vat_percentage = 24 + end + + -- change threshold percentages for showing changes in folded format + if not prefs.oneline_threshold_high then + prefs.oneline_threshold_high = 1.3 + end + if not prefs.oneline_threshold_low then + prefs.oneline_threshold_low = 0.7 + end + + -- url to open when clicked + if not prefs.click_url then + prefs.click_url = "https://www.sahkonhintatanaan.fi/" + end +end + +function get_url() + -- at most about 35 hours are known in advance; fetch all known prices + local end_offset = 2*24*60*60 + local end_ts = os.time() + end_offset + return string.format(url_base, prefs.bidding_zone, end_ts) +end + +function on_alarm() + if os.time() > next_fetch_ts then + http:get(get_url()) + end +end + +function on_network_result(result, code) + if code >= 200 and code < 299 then + parse_result(result) + draw_widget(true) + end +end + +function on_tick(t) + local ts = os.time() + if next_redraw_ts and ts > next_redraw_ts then + draw_widget(true) + end +end + +function on_click() + if not ui:folding_flag() then + system:open_browser(prefs.click_url) + else + draw_widget(false) + end +end + +function parse_result(result) + price_data = json.decode(result) + local price_count = #price_data.unix_seconds + if price_count < 2 then + return + end + + price_interval = price_data.unix_seconds[2] - price_data.unix_seconds[1] + if price_data.unit == "EUR/MWh" then + price_unit = "c/kWh" + unit_multiplier = 0.1 + else + price_unit = price_data.unit + unit_multiplier = 1 + end + + -- assume next day is known 8 hours before it starts + -- (eg. Nord Pool Spot typically publishes dayahead prices at 14 local time) + local next_fetch_offset = 8*60*60 + local end_of_data_ts = price_data.unix_seconds[price_count] + price_interval + next_fetch_ts = end_of_data_ts - next_fetch_offset +end + +function get_current_idx() + local t = os.time() + for i = 1, #price_data.unix_seconds do + local ts = price_data.unix_seconds[i] + if ts < t and t < (ts+price_interval) then + return i + end + end +end + +function price(i) + return price_data.price[i] +end + +function get_display_price(idx) + local mul = (1.0 + (prefs.vat_percentage / 100.0)) * unit_multiplier + -- NOTE: float rounding in string.format doesn't work so do it here + return math.floor(100.0 * price(idx) * mul + 0.5) / 100.0 +end + +function get_display_time(idx) + return os.date("%H", price_data.unix_seconds[idx]) +end + +function format_price(idx) + return string.format("%0.2f", get_display_price(idx)) +end + +function format_price_and_unit(idx) + return string.format("%s %s", format_price(idx), price_unit) +end + +function format_oneline(idx) + local more_prices = "" + local more_count = 0 + local cur_price = price(idx) + for i = idx+1, #price_data.price do + if price(i) > prefs.oneline_threshold_high * cur_price + or price(i) < prefs.oneline_threshold_low * cur_price then + more_count = more_count + 1 + more_prices = more_prices .. string.format("⋄ %s′ %s ", get_display_time(i), get_display_price(i)) + cur_price = price(i) + if more_count > 3 then + break + end + end + end + return string.format("%s %s", format_price_and_unit(idx), more_prices) +end + +-- NOTE: using timestamps would be better than indices, but the chart element +-- doesn't support times spanning multiple days properly +function make_chart_data(idx) + local chart = {} + for i = idx, #price_data.price do + table.insert(chart, { + i-1, + get_display_price(i) + }) + end + return chart +end + +function draw_widget(fold) + ui:set_folding_flag(fold) + local idx = get_current_idx() + if not idx then + ui:show_text("Error: no current price data") + -- request fetch on next on_alarm and don't redraw before that + next_fetch_ts = 0 + next_redraw_ts = nil + return + end + + next_redraw_ts = price_data.unix_seconds[idx+1] + ui:set_title(string.format("Electricity spot price: %s", format_price_and_unit(idx))) + ui:show_chart(make_chart_data(idx), "x: int, y: float", "", true, format_oneline(idx)) +end -- 2.43.0 From 1c2ab3341a1d472e3b3347c231c1aec595900e69 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 16 May 2024 14:21:05 +0400 Subject: [PATCH 111/204] Add info and sample for SVG icons and prefs edit dialog --- README.md | 10 +++++++++- README_RICH_UI.md | 2 +- samples/prefs-widget3.lua | 31 +++++++++++++++++++++++++++++++ samples/svg-sample.lua | 12 ++++++++++++ 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 samples/prefs-widget3.lua create mode 100644 samples/svg-sample.lua diff --git a/README.md b/README.md index 4518531..ae0f3af 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,11 @@ The type of script is determined by the line (meta tag) at the beginning of the # Changelog +### 5.3.0 + +* Added `prefs:show_dialog` method +* Added support for SVG icons to the Rich UI API + ### 5.2.3 * Added `on_load()` callback @@ -139,7 +144,8 @@ The `ui:show_chart()` function takes a string as its third argument to format th * `number` - an ordinary number with group separation; * `float` - the same, but with two decimal places; * `date` - date in day.month format; -* `time` - time in hours:minutes format. +* `time` - time in hours:minutes format; +* `none` - disable. ### Clicks @@ -671,6 +677,8 @@ end The `new_key` will be present in the table even after the AIO Launcher has been restrated. +The `show_dialog()` method automatically creates a window of current settings from fields defined in prefs. The window will display all fields with a text key and a value of one of three types: string, number, or boolean. All other fields of different types will be omittedi. Fields whose names start with an underscore will also be omitted. Script will be reloaded on settings save. + ## Animation and real time updates _Available only in widget scripts._ diff --git a/README_RICH_UI.md b/README_RICH_UI.md index be22686..58b3c8a 100644 --- a/README_RICH_UI.md +++ b/README_RICH_UI.md @@ -72,7 +72,7 @@ Third way: display icon in the button: {"button", "Text with icon: %%fa:microphone%%"} ``` -The second method also allows displaying icons of applications and contacts. How to do this is shown in the example [samples/rich-ui-sample.lua]. +The second method also allows displaying icons of applications and contacts. How to do this is shown in the example [rich-ui-sample.lua](samples/rich-ui-sample.lua). You can also use the `icon` element to display your own icons in SVG format. Example: [svg-sample.lua](samples/svg-sample.lua). By the way, if you want the button to stretch across the entire width of the screen, you can use the expand argument: diff --git a/samples/prefs-widget3.lua b/samples/prefs-widget3.lua new file mode 100644 index 0000000..99e304a --- /dev/null +++ b/samples/prefs-widget3.lua @@ -0,0 +1,31 @@ +--[[ +This example shows how to use the prefs module +to display a settings dialog automatically generated on the screen. +]] + +prefs = require("prefs") + +function on_load() + -- Initialize settings with default values + prefs.text_field_1 = "Test" + prefs.text_field_2 = "Test #2" + prefs.numeric_field = 123 + prefs.boolean_field = false + prefs._hidden_field = "Hidden" +end + +function on_resume() + ui:show_toast("On resume called") + ui:show_text("Click to edit preferencies") +end + +function on_click() + --[[ + The `show_dialog()` method automatically creates a window of current settings from fields defined in prefs. + The window will display all fields with a text key and a value of one of three types: string, number, or boolean. + All other fields of different types will be omittedi. + Fields whose names start with an underscore will also be omitted. + Script will be reloaded on settings save. + ]] + prefs:show_dialog() +end diff --git a/samples/svg-sample.lua b/samples/svg-sample.lua new file mode 100644 index 0000000..bb62ecc --- /dev/null +++ b/samples/svg-sample.lua @@ -0,0 +1,12 @@ +local icon = [[ + + + + +]] + +function on_resume() + gui{ + {"icon", "svg:"..icon, {size = 100}}, + }.render() +end -- 2.43.0 From 7d6b9258029ac0b94fb43341454159d8a105bc7e Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 16 May 2024 14:25:40 +0400 Subject: [PATCH 112/204] Add info and sample for SVG icons and prefs edit dialog #fix --- README_RICH_UI.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_RICH_UI.md b/README_RICH_UI.md index 58b3c8a..41fb90c 100644 --- a/README_RICH_UI.md +++ b/README_RICH_UI.md @@ -72,7 +72,7 @@ Third way: display icon in the button: {"button", "Text with icon: %%fa:microphone%%"} ``` -The second method also allows displaying icons of applications and contacts. How to do this is shown in the example [rich-ui-sample.lua](samples/rich-ui-sample.lua). You can also use the `icon` element to display your own icons in SVG format. Example: [svg-sample.lua](samples/svg-sample.lua). +The second method also allows displaying icons of applications and contacts. How to do this is shown in the example [rich-gui-sample.lua](samples/rich-gui-sample.lua). You can also use the `icon` element to display your own icons in SVG format. Example: [svg-sample.lua](samples/svg-sample.lua). By the way, if you want the button to stretch across the entire width of the screen, you can use the expand argument: -- 2.43.0 From 9ab0ab3934e2df7ae24d71b547ed178cc7fbdced Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 16 May 2024 15:27:31 +0400 Subject: [PATCH 113/204] Add on_settings to scripts without it --- README.md | 1 + community/counter-widget.lua | 4 ++++ community/kodi-remote-widget.lua | 4 ++++ community/net-file-widget.lua | 7 ++++++- community/period-progress-widget.lua | 5 +++++ community/uptimerobot-2-widget.lua | 6 +++++- community/uptimerobot-widget.lua | 5 +++++ samples/currencies-widget.lua | 4 ++++ 8 files changed, 34 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ae0f3af..159e739 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ The type of script is determined by the line (meta tag) at the beginning of the * Added `prefs:show_dialog` method * Added support for SVG icons to the Rich UI API +* To show settings dialog you must declare `on_settings` function ### 5.2.3 diff --git a/community/counter-widget.lua b/community/counter-widget.lua index bcc460e..a5c97b5 100644 --- a/community/counter-widget.lua +++ b/community/counter-widget.lua @@ -47,6 +47,10 @@ function on_click() settings:show_dialog() end +function on_settings() + settings:show_dialog() +end + -- utils function get_milestone_idx(passed) diff --git a/community/kodi-remote-widget.lua b/community/kodi-remote-widget.lua index 970eb6e..b2be331 100644 --- a/community/kodi-remote-widget.lua +++ b/community/kodi-remote-widget.lua @@ -93,6 +93,10 @@ function on_network_result_cmd(result) end end +function on_settings() + settings:show_dialog() +end + -- utils function init_url_from_settings() diff --git a/community/net-file-widget.lua b/community/net-file-widget.lua index f292415..deafa03 100644 --- a/community/net-file-widget.lua +++ b/community/net-file-widget.lua @@ -14,9 +14,14 @@ function on_resume() end function on_click() - aio:show_args_dialog() + settings:show_dialog() end function on_network_result(result) ui:show_text(result) end + +function on_settings() + settings:show_dialog() +end + diff --git a/community/period-progress-widget.lua b/community/period-progress-widget.lua index 8be2091..b5052cf 100644 --- a/community/period-progress-widget.lua +++ b/community/period-progress-widget.lua @@ -31,3 +31,8 @@ function init_progressbar() percent = math.floor((current_time - start_period) / ((end_period - start_period) / 100)) ui:show_progress_bar(name_period..": "..percent.."%", current_time - start_period, end_period - start_period, "#7069f0ae") end + +function on_settings() + settings:show_dialog() +end + diff --git a/community/uptimerobot-2-widget.lua b/community/uptimerobot-2-widget.lua index 722d528..296a043 100644 --- a/community/uptimerobot-2-widget.lua +++ b/community/uptimerobot-2-widget.lua @@ -65,5 +65,9 @@ function on_network_result(result, code) end ui:show_buttons(names, colours) +end + +function on_settings() + settings:show_dialog() +end -end \ No newline at end of file diff --git a/community/uptimerobot-widget.lua b/community/uptimerobot-widget.lua index fb1a5a7..44cdff5 100644 --- a/community/uptimerobot-widget.lua +++ b/community/uptimerobot-widget.lua @@ -91,3 +91,8 @@ function table_to_tables(tab, num) return out_tab end + +function on_settings() + settings:show_dialog() +end + diff --git a/samples/currencies-widget.lua b/samples/currencies-widget.lua index 41c78ee..801eb3e 100644 --- a/samples/currencies-widget.lua +++ b/samples/currencies-widget.lua @@ -92,6 +92,10 @@ function create_tab(result) return tab end +function on_settings() + settings:show_dialog() +end + -- utils -- function get_formatted_change_text(change) -- 2.43.0 From 73b85a1a5cac8dc501d96f8ea4e5ea6fc8f1a7d7 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 16 May 2024 15:32:08 +0400 Subject: [PATCH 114/204] Add settings to Electricity spot price widget --- community/electricity-price-widget.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/community/electricity-price-widget.lua b/community/electricity-price-widget.lua index a3f3c83..023c1e7 100644 --- a/community/electricity-price-widget.lua +++ b/community/electricity-price-widget.lua @@ -181,3 +181,9 @@ function draw_widget(fold) ui:set_title(string.format("Electricity spot price: %s", format_price_and_unit(idx))) ui:show_chart(make_chart_data(idx), "x: int, y: float", "", true, format_oneline(idx)) end + +function on_settings() + if (prefs.show_dialog) then + prefs:show_dialog() + end +end -- 2.43.0 From 42473099eb8999bdccb3324e25c4a15647a4484d Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 16 May 2024 15:36:24 +0400 Subject: [PATCH 115/204] Update some scripts --- community/amdroid-nextalarm-app-widget.lua | 19 +- community/google-search-app-widget.lua | 138 +++++++++------ community/quickactions-widget.lua | 193 ++++++++++----------- 3 files changed, 192 insertions(+), 158 deletions(-) diff --git a/community/amdroid-nextalarm-app-widget.lua b/community/amdroid-nextalarm-app-widget.lua index 63c4f59..73ae020 100644 --- a/community/amdroid-nextalarm-app-widget.lua +++ b/community/amdroid-nextalarm-app-widget.lua @@ -1,21 +1,22 @@ -- name = "Amdroid Next Alarm" --- description = "AIO wrapper for the Amdroid next alarm app widget" +-- description = "AIO wrapper for the Amdroid Next alarm app widget" -- type = "widget" --- author = "Theodor Galanis" --- version = "1.0.2" +-- author = "Theodor Galanis (t.me/TheodorGalanis)" +-- version = "1.10" -- foldable = "false" -- uses_app = "com.amdroidalarmclock.amdroid" local prefs = require "prefs" local next_alarm = "" -local accent="#FFFFFF" +local accent="#888888" function on_resume() if not widgets:bound(prefs.wid) then setup_app_widget() end accent = aio:colors().accent + primary = aio:colors().primary_text widgets:request_updates(prefs.wid) end @@ -28,8 +29,10 @@ function on_app_widget_updated(bridge) if next_alarm ~= nil then my_gui=gui{ - {"text", " %%fa:alarm-clock%% "..next_alarm.."", {gravity="center_h", color=accent}} - } + {"icon", "fa:alarm-clock", {gravity="center_h|center_v",color = accent}}, +{"spacer", 2}, + {"text", next_alarm, {gravity="anchor_prev"}} + } else my_gui=gui{ {"text", "Empty", {gravity="center_h" }} @@ -42,6 +45,10 @@ function on_click(idx) w_bridge:click(next_alarm) end +function on_settings() +ui:show_dialog("Amdroid app Next Alarm widget", "This script wrapper uses Amdroid app's Next alarm widget to display the next scheduled alarm. No settings are required.") +end + function setup_app_widget() local id = widgets:setup("com.amdroidalarmclock.amdroid/com.amdroidalarmclock.amdroid.widgets.NextAlarmWidgetProvider") diff --git a/community/google-search-app-widget.lua b/community/google-search-app-widget.lua index a8adfb9..3822499 100644 --- a/community/google-search-app-widget.lua +++ b/community/google-search-app-widget.lua @@ -1,15 +1,14 @@ -- name = "Google search" --- description = "AIO wrapper for the Google search app widget" +-- description = "AIO wrapper for the Google search app widget - open widget settings for options" -- type = "widget" --- author = "Theodor Galanis" --- version = "2.0" +-- author = "Theodor Galanis (t.me/TheodorGalanis)" +-- version = "2.5" -- foldable = "false" -- uses_app: "com.google.android.googlequicksearchbox" local prefs = require "prefs" local w_bridge = nil -local gravs = {} local indices = {} function on_alarm() @@ -17,84 +16,113 @@ function on_alarm() setup_app_widget() end if not prefs.mode then - prefs.mode = 1 + prefs.mode = 1 end - mode = prefs.mode - gravs = {"left", "right"} - indices = {1, 3, 5, 7} - if mode == 2 then - gravs= reverse(gravs) - indices = reverse(indices) - end - widgets:request_updates(prefs.wid) + mode = prefs.mode + indices = set_indices() + widgets:request_updates(prefs.wid) end function on_app_widget_updated(bridge) w_bridge = bridge local tab = { - {"button", "            %%fa:magnifying-glass%%          ", {gravity = gravs[1]}}, - {"spacer", 2}, - {"button", "    %%fa:asterisk%%  ", {gravity = gravs[2]}}, - {"spacer", 2}, - {"button", "    %%fa:microphone%%  "}, - {"spacer", 2}, - {"button", "    %%fa:camera%%  "} - } +{"button", "fa:magnifying-glass", {expand = true}}, +{"spacer", 2}, +{"button", "fa:sun-cloud"}, +{"spacer", 2}, +{"button", "fa:asterisk"}, +{"spacer", 2}, +{"button", "fa:microphone"}, +{"spacer", 2}, +{"button", "fa:camera"} +} - if mode==1 then - my_gui = gui(tab) - else - my_gui =gui(reverse(tab)) - end - - my_gui.render() +tab = set_gui(tab) +my_gui = gui(tab) +my_gui.render() end function on_click(idx) - if idx == indices[1] then - w_bridge:click("image_4") - elseif idx == indices[2] then - w_bridge:click("image_7") - elseif idx == indices[3] then - w_bridge:click("image_9") - elseif idx == indices[4] then - w_bridge:click("image_10") - else return - end +if idx == indices[1] then + w_bridge:click("image_4") +elseif idx == indices[2] then + intent:start_activity(open_weather()) +elseif idx == indices[3] then + w_bridge:click("image_7") +elseif idx == indices[4] then + w_bridge:click("image_9") +elseif idx == indices[5] then + w_bridge:click("image_10") + else return +end end function on_settings() - local tab = {"Left-handed mode", "Right-handed mode"} - ui:show_radio_dialog("Select mode", tab, mode) +local tab = {"Left-handed mode with weather", "Left-handed mode, no weather", "Right-handed mode with weather", "Right-handed mode, no weather" } +ui:show_radio_dialog("Select mode", tab, mode) end function on_long_click(idx) - if idx == indices[1] then - ui:show_toast("Google search") - elseif idx == indices[2] then - ui:show_toast("Google discover") - elseif idx == indices[3] then - ui:show_toast("Google voice search") - elseif idx == indices[4] then - ui:show_toast("Google Lens") - end +if idx == indices[1] then +ui:show_toast("Google search") +elseif idx == indices[2] then +ui:show_toast("Google weather") +elseif idx == indices[3] then + ui:show_toast("Google discover") +elseif idx == indices[4] then + ui:show_toast("Google voice search") +elseif idx == indices[5] then + ui:show_toast("Google Lens") +end end function on_dialog_action(data) - if data == -1 then - return - end - prefs.mode = data - on_alarm() +if data == -1 then +return +end +prefs.mode = data +on_alarm() end function setup_app_widget() local id = widgets:setup("com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.SearchWidgetProvider") - if (id ~= nil) then + if (id ~= nil) then prefs.wid = id else ui:show_text("Can't add widget") return end end + +function set_indices() +local temp = {1, 3, 5, 7, 9} + if mode == 2 then +temp = {1, 9, 3, 5, 7} +elseif mode == 3 then +temp = reverse (temp) +elseif mode == 4 then +temp = {7, 9, 5, 3, 1} +end +return temp +end + +function set_gui(tab) +local temp = tab + if mode == 2 or mode == 4 then +table.remove(tab, 3) +table.remove(tab, 3) +end +if mode > 2 then + temp = reverse(temp) +end +return temp +end + +function open_weather() +local tab ={} +tab.category = "MAIN" +tab.package = "com.google.android.googlequicksearchbox" +tab.component = "com.google.android.googlequicksearchbox/com.google.android.apps.search.weather.WeatherExportedActivity" +return tab +end diff --git a/community/quickactions-widget.lua b/community/quickactions-widget.lua index a30468b..0c0ddd2 100644 --- a/community/quickactions-widget.lua +++ b/community/quickactions-widget.lua @@ -1,49 +1,44 @@ -- name = "Quick Actions" -- type = "widget" --- description = "Launcher selected actions widget - long click button for options, open widget settings for list of buttons" +-- description = "Launcher selected actions widget" +-- arguments_help = "Long click button for options, open widget settings for list of buttons" --foldable = "true" -- author = "Theodor Galanis" --- version = "3.0" +-- version = "2.5" -prefs = require "prefs" -prefs._name = "quickactions" +md_colors = require "md_colors" -local actions = { "quick_menu", "settings", "apps_menu", "ui_settings", "headers", "quick_apps_menu", "refresh", "restart", "notify", "clear_notifications", "quick_settings", "show_recents", "private_mode", "screen_off", "fold", "unfold", "scroll_down", "scroll_up", "add_note", "add_task", "add_purchase", "shortcuts", "send_mail", "voice", "one_handed", "right_handed", "camera", "flashlight", "dialer", "search"} +local icons = { "fa:pen", "fa:edit", "fa:indent", "fa:bars", "fa:sliders-h", "fa:redo", "fa:power-off", "fa:bring-forward", "fa:eraser", "fa:tools", "fa:layer-minus", "fa:layer-group", "fa:user-shield", "fa:lock", "fa:chevron-down", "fa:chevron-up", "fa:notes-medical", "fa:circle-dot", "fa:envelope", "fa:square-full", "fa:microphone", "fa:hand", "fa:search"} -local icons = { "fa:ellipsis-vertical", "fa:sliders-h", "fa:indent", "fa:paintbrush", "fa:bars", "fa:share-from-square", "fa:redo", "fa:power-off", "fa:bring-forward", "fa:eraser", "fa:square-ellipsis", "fa:square-full", "fa:user-shield", "fa:lock", "fa:layer-minus", "fa:layer-group", "fa:chevron-down", "fa:chevron-up", "fa:notes-medical", "fa:list-check", "fa:tag", "fa:share", "fa:envelope", "fa:microphone", "fa:hand", "fa:right-to-bracket", "fa:camera", "fa:brightness", "fa:phone", "fa:search"} +local names = {"Quick menu", "Quick apps menu", "Applications menu", "Toggle headers", "Settings", "Screen refresh", "Restart AIO launcher", "Notifications panel", "Clear notifications", "Quick settings", "Fold all widgets", "Unfold all widgets", "Private mode", "Screen off", "Scroll down", "Scroll up", "Add note", "Start audio recording", "Send mail", "Recent apps", "Voice command", "One-handed mode", "Search"} -local cols = { "#6A1B9A", "#4527A0", "#8E24AA", "#FF6F00", "#E65100", "#0D47A1", "#546E7A", "#1B5E20", "#689F38", "#1565C0", "#F06292", "#0073DD", "#00796B", "#424242", "#3F51B5", "#3F51B5", "#AB47BC", "#AB47BC", "#D81B60", "#F57C00", "#9E9D24", "#00838F", "#B71C1C", "#512DA8", "#795548", "#5C6BC0", "#FF5252", "#FF8F00", "#B388FF", "#37474F"} +local colors = { md_colors.purple_800, md_colors.purple_600, md_colors.amber_900, md_colors.orange_900, md_colors.blue_900, md_colors.deep_purple_800, md_colors.grey_600, md_colors.green_900, md_colors.green_900, md_colors.blue_800, md_colors.pink_300, md_colors.pink_A200, md_colors.green_600, md_colors.grey_800, md_colors.teal_700, md_colors.teal_800, md_colors.orange_700, md_colors.red_800, md_colors.red_900, md_colors.deep_purple_700, md_colors.blue_700, md_colors.amber_800, md_colors.blue_grey_700} + + local actions = { "quick_menu", "quick_apps_menu", "apps_menu", "headers", "settings", "refresh", "restart", "notify", "clear_notifications", "quick_settings", "fold", "unfold", "private_mode", "screen_off", "scroll_down", "scroll_up", "add_note", "start_record", "send_mail", "show_recents", "voice", "one_handed", "search"} local pos = 0 -local buttons,colors = {},{} -function on_alarm() - args = get_args() - if not prefs.args then - prefs.args = args.action - end - indexes = get_indexes(prefs.args, args.action) - ui:show_buttons(get_buttons()) +function on_resume() + if next(settings:get()) == nil then + set_default_args() + end + local buttons,colors = get_buttons() + ui:show_buttons(buttons, colors) end function on_click(idx) - if idx > #prefs.args then - on_settings() - return - end - local action = prefs.args[idx] - aio:do_action(action) - on_alarm() + pos = idx + redraw() end function on_long_click(idx) - local label = "" - pos = idx - if idx > #prefs.args then - return - end - label = get_label(args.action[indexes[idx]]) - ui:show_context_menu({{"angle-left",""},{"ban",""},{"angle-right",""},{args.icon[indexes[idx]]:gsub("fa:",""),label}}) + pos = idx + local tab = settings:get() + label = get_label(actions[get_checkbox_idx()[idx]]) + if label == nil then + label = names[get_checkbox_idx()[idx]] + end + ui:show_context_menu({{"angle-left",""},{"ban",""},{"angle-right",""},{icons[get_checkbox_idx()[idx]]:gsub("fa:",""),label}}) end function on_context_menu_click(menu_idx) @@ -53,92 +48,96 @@ function on_context_menu_click(menu_idx) remove() elseif menu_idx == 3 then move(1) + elseif menu_idx == 4 then + redraw() end end function on_dialog_action(data) - if data == -1 then - return - end - local tab = {} - for i,v in ipairs(data) do - tab[i] = args.action[v] - end - prefs.args = tab - on_alarm() + if data == -1 then + return + end + settings:set(data) + on_resume() end function on_settings() - local labels = {} - for i = 1, #icons do - table.insert(labels, get_label(args.action[i])) - end - ui:show_checkbox_dialog("Select actions", labels, indexes) +axions = aio:actions() +lab = {} +for i = 1, #axions do +lav = get_label(actions[i]) + if lav == nil then + table.insert(lab,names[i]) + else + table.insert(lab, lav) + end + end + ui:show_checkbox_dialog("Select actions", lab, get_checkbox_idx()) end --utilities-- -function move(x) - local tab = prefs.args - if (pos*x == -1) or (pos*x == #tab) then - return - end - local cur = tab[pos] - tab[pos] = tab[pos+x] - tab[pos+x] = cur - prefs.args = tab - on_alarm() +function redraw() + local buttons,colors = get_buttons() + local checkbox_idx = get_checkbox_idx() + local action = actions[checkbox_idx[pos]] +aio:do_action(action) + ui:show_buttons(buttons, colors) end -function remove() - local tab = prefs.args - table.remove(tab,pos) - prefs.args = tab - on_alarm() +function set_default_args() + local args = {} + for i = 1, #actions do + table.insert(args, i) + end + settings:set(args) end - -function get_label(name) - local lab="" - local axions = aio:actions() - if name == "clear_notifications" then - lab = aio:res_string("clear_notifications","Clear notifications") - else for _, action in ipairs(axions) do - if action["name"] == name then - lab = action["label"] - end - end -end -return lab -end - -function get_args() - local tab = {} - tab.action = actions - tab.icon = icons - tab.color = cols - return tab +function get_checkbox_idx() + local tab = settings:get() + for i = 1, #tab do + tab[i] = tonumber(tab[i]) + end + return tab end function get_buttons() - buttons,colors = {},{} - for i,v in ipairs(indexes) do - table.insert(buttons, args.icon[v]) - table.insert(colors, args.color[v]) - end - return buttons,colors + local buttons,bcolors = {},{} + local checkbox_idx = get_checkbox_idx() + for i = 1, #checkbox_idx do + table.insert(buttons, icons[checkbox_idx[i]]) + table.insert(bcolors, colors[checkbox_idx[i]]) + end + return buttons,bcolors end - -function get_indexes(tab1,tab2) - local tab = {} - for i1,v1 in ipairs(tab1) do - for i2,v2 in ipairs(tab2) do - if v1 == v2 then - tab[i1] = i2 - break - end - end - end - return tab +function move(x) + local tab = settings:get() + if (pos == 1 and x < 0) or (pos == #tab and x > 0) then + return + end + local cur = tab[pos] + local prev = tab[pos+x] + tab[pos+x] = cur + tab[pos] = prev + settings:set(tab) + local buttons,colors = get_buttons() + ui:show_buttons(buttons, colors) end + +function remove() + local tab = settings:get() + table.remove(tab,pos) + settings:set(tab) + local buttons,colors = get_buttons() + ui:show_buttons(buttons, colors) +end + +function get_label(name) +axions = aio:actions() + for _, action in ipairs(axions) do + if action["name"] == name then + return action["label"] + end + end +end \ No newline at end of file -- 2.43.0 From 430379546c342eb51ffe6525663fd9ebdda37e0c Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 18 May 2024 13:51:38 +0400 Subject: [PATCH 116/204] Add info about notifications to README --- README.md | 23 ++++++++++++++++++++-- samples/notify_send_sample.lua | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 samples/notify_send_sample.lua diff --git a/README.md b/README.md index 159e739..b57aa99 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,8 @@ The type of script is determined by the line (meta tag) at the beginning of the ### 5.3.0 * Added `prefs:show_dialog` method +* Added `system:show_notify()` and `system:cancel_notify()` methods * Added support for SVG icons to the Rich UI API -* To show settings dialog you must declare `on_settings` function ### 5.2.3 @@ -311,6 +311,23 @@ The function takes a command table of this format as a parameter: The result of executing a shell command is sent to the `on_shell_result(string)` callback. +* `system:show_notify(table)` - show system notifycation; +* `system:cancel_notify()` - cancel notification. + +These two functions can be used to display, update, and delete system notifications. The possible fields for the `table` (each of them is optional) are: + +``` +`message` - the message displayed in the notification; +`silent` - true if the notification should be silent; +`action1` - the name of the first notification action; +`action2` - the name of the second notification action; +`action3` - the name of the third notification action. +``` + +When the notification is clicked, the main launcher window will open. When one of the three actions is clicked, the callback `on_notify_action(idx, name)` will be executed with the action's index and name as parameters. + +_Keep in mind that the callback will only be executed for scripts of type `widget`._ + ## Intents * `intent:start_activity(table)` - starts activity with intent described in the table; @@ -589,11 +606,13 @@ _Avaialble from: 4.1.0_ All data are returned in `on_cloud_result(meta, content)`. The first argument is the metadata, either a metadata table (in the case of `list_dir()`) or an error message string. The second argument is the contents of the file (in the case of `get_file()`). -## Notifications +## Reading notifications _Available only in widget scripts._ _Avaialble from: 4.1.3_ +_This module is intended for reading notifications from other applications. To send notifications, use the `system` module._ + * `notify:request_current()` - requests current notifications from the launcher; * `notify:open(key)` - opens notification with specified key; * `notify:close(key)` - removes the notification with the specified key; diff --git a/samples/notify_send_sample.lua b/samples/notify_send_sample.lua new file mode 100644 index 0000000..d4bd69b --- /dev/null +++ b/samples/notify_send_sample.lua @@ -0,0 +1,35 @@ +function on_resume() + ui:show_lines{ + "Show notify", + "Update notify", + "Cancel notify", + } +end + +function on_click(idx) + if idx == 1 then + system:show_notify{ + message = "Just message", + silent = true, + action1 = "cancel", + } + elseif idx == 2 then + system:show_notify{ + message = "Message updated", + silent = true, + action1 = "cancel", + action2 = "action #2", + action3 = "action #3", + } + else + system:cancel_notify() + end +end + +function on_notify_action(idx, action) + ui:show_toast("action: "..idx..": "..action) + + if action == "cancel" then + system:cancel_notify() + end +end -- 2.43.0 From acb73cc4deab494dfcfa9d796c2b8d7deaeca33e Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 19 May 2024 17:18:51 +0400 Subject: [PATCH 117/204] Remove bitcoin from builder sample --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index b57aa99..55a8a76 100644 --- a/README.md +++ b/README.md @@ -280,7 +280,6 @@ The function takes a command table of this format as a parameter: `player` - player controls; `health` - health data; `weather [NUM]` - weather forecast for NUM days; -`bitcoin` - bitcoin rate chart; `worldclock [TIME_ZONE]` - time in the given TIME_ZONE; `notify [NUM]` - last NUM notifications; `dialogs [NUM]` - last NUM dialogs; -- 2.43.0 From 4e930db750c391dda5c6834e0db8b50df4ad0f4f Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 19 May 2024 17:22:53 +0400 Subject: [PATCH 118/204] README: add note about html formatting --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 55a8a76..e245ae8 100644 --- a/README.md +++ b/README.md @@ -175,6 +175,8 @@ First line
Second line You can also use Markdown markup. To do this, add the prefix `%%mkd%%` to the beginning of the line. Or you can disable the formatting completely with the prefix `%%txt%%`. +_Keep in mind: HTML formatting and icons will not work if you use the second parameter in `ui:show_lines()`._ + ### Icons You can insert FontAwesome icons inside the text, to do this use this syntax: `%%fa:ICON_NAME%%. For example: @@ -183,7 +185,9 @@ You can insert FontAwesome icons inside the text, to do this use this syntax: `% ui:show_text("This is the text with icons %%fa:face-smile%% %%fa:poo%% and styles") ``` -The `ui:show_buttons()` function supports Fontawesome icons. Simply specify `fa:icon_name` as the button name, for example: `fa:play`. (Note: AIO only supports icons up to Fontawesome 6.3.0.) +The `ui:show_buttons()` function supports Fontawesome icons. Simply specify `fa:icon_name` as the button name, for example: `fa:play`. + +_Note: AIO only supports icons up to Fontawesome 6.3.0._ ## Dialogs -- 2.43.0 From ad9af4c2b6d5152ca8c694bbe75b6a37681009ab Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 21 May 2024 17:50:55 +0400 Subject: [PATCH 119/204] Add prefs sample for the side menu --- samples/prefs-menu.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 samples/prefs-menu.lua diff --git a/samples/prefs-menu.lua b/samples/prefs-menu.lua new file mode 100644 index 0000000..e116d5e --- /dev/null +++ b/samples/prefs-menu.lua @@ -0,0 +1,31 @@ +-- type = "drawer" + +-- This script shows how to manage settings in the side menu script + +local prefs = require("prefs") + +function on_drawer_open() + -- Init prefs table with default values + if prefs.elem1 == nil then + prefs.elem1 = "Element #1" + end + if prefs.elem2 == nil then + prefs.elem2 = "Element #2" + end + if prefs.elem3 == nil then + prefs.elem3 = "Element #3" + end + + -- Show values from the prefs table + drawer:show_list{ + prefs.elem1, + prefs.elem2, + prefs.elem3, + } +end + +function on_click() + -- Show prefs edit dialog + -- On the next open side menu it will show changed values + prefs:show_dialog() +end -- 2.43.0 From 42d4d4a104b918c142a240e24c0b5d96b06c9a44 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 27 May 2024 16:35:12 +0400 Subject: [PATCH 120/204] Add another Rich UI sample --- samples/rich-gui-basic-sample2.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 samples/rich-gui-basic-sample2.lua diff --git a/samples/rich-gui-basic-sample2.lua b/samples/rich-gui-basic-sample2.lua new file mode 100644 index 0000000..3c27648 --- /dev/null +++ b/samples/rich-gui-basic-sample2.lua @@ -0,0 +1,14 @@ +-- name = "Rich GUI Basic sample #2" + +function on_resume() + my_gui = gui{ + {"progress", "Progress #1", {progress = 30}}, + {"new_line", 1}, + {"progress", "Progress #2", {progress = 60}}, + {"new_line", 1}, + {"progress", "Progress #3", {progress = 90}}, + } + + my_gui.render() +end + -- 2.43.0 From d5101ca34bce8d90210a824de413bd46fc6fef18 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 27 May 2024 16:40:17 +0400 Subject: [PATCH 121/204] Update utils.lua as of AIO Launcher 5.3.1 --- README.md | 3 + lib/utils.lua | 122 +++++++++++++++----- samples/utils-tests.lua | 242 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 342 insertions(+), 25 deletions(-) create mode 100644 samples/utils-tests.lua diff --git a/README.md b/README.md index e245ae8..e8d285c 100644 --- a/README.md +++ b/README.md @@ -775,6 +775,9 @@ The standard Lua API is extended with the following features: * `string:split(delimeter)` - splits the string using the specified delimiter and returns a table; * `string:replace(regexp, string)` - replaces the text found by the regular expression with another text; +* `string:trim()` - removes leading and trailing spaces from the string; +* `string:starts_with(substring)` - returns true if the string starts with the specified substring; +* `string:ends_with(substring)` - returns true if the string ends with the specified substring; * `slice(table, start, end)` - returns the part of the table starting with the `start` index and ending with `end` index; * `index(table, value)` - returns the index of the table element; * `key(table, value)` - returns the key of the table element; diff --git a/lib/utils.lua b/lib/utils.lua index 0918600..2141282 100644 --- a/lib/utils.lua +++ b/lib/utils.lua @@ -1,5 +1,25 @@ -- Standard AIO Launcher library +function string:trim() + if #self == 0 then return self end + + return self:match("^%s*(.-)%s*$") +end + +function string:starts_with(start_str) + if #self == 0 or #self < #start_str then return false end + if start_str == nil or start_str == "" then return true end + + return self:sub(1, #start_str) == start_str +end + +function string:ends_with(end_str) + if #self == 0 or #self < #end_str then return false end + if end_str == nil or end_str == "" then return true end + + return self:sub(-#end_str) == end_str +end + function string:split(sep) if sep == nil then sep = "%s" @@ -39,11 +59,6 @@ function index(tab, val) return 0 end --- Deprecated -function get_index(tab, val) - return index(tab, val) -end - function key(tab, val) for index, value in pairs(tab) do if value == val then @@ -54,20 +69,19 @@ function key(tab, val) return 0 end --- Deprecated -function get_key(tab, val) - return key(tab, val) -end - function concat(t1, t2) for _,v in ipairs(t2) do table.insert(t1, v) end end --- Deprecated -function concat_tables(t1, t2) - concat(t1, t2) +function contains(table, val) + for i=1, #table do + if table[i] == val then + return true + end + end + return false end function reverse(tab) @@ -78,20 +92,20 @@ function reverse(tab) end function serialize(tab, ind) - ind = ind and (ind .. " ") or " " + ind = ind and (ind .. " ") or " " local nl = "\n" local str = "{" .. nl for k, v in pairs(tab) do local pr = (type(k)=="string") and ("[\"" .. k .. "\"] = ") or "" str = str .. ind .. pr if type(v) == "table" then - str = str .. serialize(v, ind) .. "," + str = str .. serialize(v, ind) .. ",\n" elseif type(v) == "string" then - str = str .. "\"" .. tostring(v) .. "\"," + str = str .. "\"" .. tostring(v) .. "\",\n" elseif type(v) == "number" or type(v) == "boolean" then - str = str .. tostring(v) .. "," + str = str .. tostring(v) .. ",\n" else - str = str .. "[[" .. tostring(v) .. "]]," + str = str .. "[[" .. tostring(v) .. "]],\n" end end str = str:gsub(".$","") @@ -99,6 +113,21 @@ function serialize(tab, ind) return str end +function deep_copy(orig) + local orig_type = type(orig) + local copy + if orig_type == 'table' then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[deep_copy(orig_key)] = deep_copy(orig_value) + end + setmetatable(copy, deep_copy(getmetatable(orig))) + else + copy = orig + end + return copy +end + function round(x, n) local n = math.pow(10, n or 0) local x = x * n @@ -109,13 +138,34 @@ end function use(module, ...) for k,v in pairs(module) do if _G[k] then - io.stderr:write("use: skipping duplicate symbol ", k, "\n") + print("use: skipping duplicate symbol ", k, "\n") else _G[k] = module[k] end end end +function for_each(tbl, callback) + for index, value in ipairs(tbl) do + callback(value, index, tbl) + end +end + +-- Deprecated +function get_index(tab, val) + return index(tab, val) +end + +-- Deprecated +function get_key(tab, val) + return key(tab, val) +end + +-- Deprecated +function concat_tables(t1, t2) + concat(t1, t2) +end + -- Functional Library -- -- @file functional.lua @@ -146,6 +196,29 @@ function filter(func, tbl) return newtbl end +-- skip(table, N) +-- e.g: skip({1,2,3,4}, 2) -> {3,4} +function skip(tbl, N) + local result = {} + for i = N+1, #tbl do + table.insert(result, tbl[i]) + end + return result +end + +-- take(table, N) +-- e.g: take({1,2,3,4}, 2) -> {1,2} +function take(tbl, N) + local result = {} + for i = 1, N do + if tbl[i] == nil then + break + end + table.insert(result, tbl[i]) + end + return result +end + -- head(table) -- e.g: head({1,2,3}) -> 1 function head(tbl) @@ -158,13 +231,12 @@ end -- XXX This is a BAD and ugly implementation. -- should return the address to next porinter, like in C (arr+1) function tail(tbl) - if table.getn(tbl) < 1 then + if #tbl < 1 then return nil else local newtbl = {} - local tblsize = table.getn(tbl) local i = 2 - while (i <= tblsize) do + while (i <= #tbl) do table.insert(newtbl, i-1, tbl[i]) i = i + 1 end @@ -190,9 +262,9 @@ end -- curry(f,g) -- e.g: printf = curry(io.write, string.format) -- -> function(...) return io.write(string.format(unpack(arg))) end -function curry(f,g) +function curry(f, g) return function (...) - return f(g(unpack(arg))) + return f(g(table.unpack({...}))) end end @@ -225,7 +297,7 @@ end -- local is_odd = is(bind2(math.mod, 2), 0) is = function(check, expected) return function (...) - if (check(unpack(arg)) == expected) then + if (check(table.unpack({...})) == expected) then return true else return false diff --git a/samples/utils-tests.lua b/samples/utils-tests.lua new file mode 100644 index 0000000..0df6ea9 --- /dev/null +++ b/samples/utils-tests.lua @@ -0,0 +1,242 @@ +local print_tab = {} + +function print(str) + table.insert(print_tab, str) + ui:show_lines(print_tab) +end + +function test_trim() + assert((" hello "):trim() == "hello") + assert(("no_spaces"):trim() == "no_spaces") + assert((""):trim() == "") + assert((" "):trim() == "") + print("test_trim passed") +end + +function test_starts_with() + assert(("hello"):starts_with("he") == true) + assert(("hello"):starts_with("hello") == true) + assert(("hello"):starts_with("hi") == false) + assert((""):starts_with("he") == false) + assert(("hello"):starts_with("") == true) + print("test_starts_with passed") +end + +function test_ends_with() + assert(("hello"):ends_with("lo") == true) + assert(("hello"):ends_with("hello") == true) + assert(("hello"):ends_with("world") == false) + assert((""):ends_with("lo") == false) + assert(("hello"):ends_with("") == true) + print("test_ends_with passed") +end + +function test_split() + local result = ("a,b,c"):split(",") + assert(#result == 3 and result[1] == "a" and result[2] == "b" and result[3] == "c") + result = ("a b c"):split(" ") + assert(#result == 3 and result[1] == "a" and result[2] == "b" and result[3] == "c") + result = ("a b c"):split("%s+") + assert(#result == 3 and result[1] == "a" and result[2] == "b" and result[3] == "c") + print("test_split passed") +end + +function test_replace() + assert(("hello world"):replace("world", "Lua") == "hello Lua") + assert(("hello world world"):replace("world", "Lua") == "hello Lua Lua") + assert((""):replace("world", "Lua") == "") + print("test_replace passed") +end + +function test_slice() + local result = slice({1, 2, 3, 4, 5}, 2, 4) + assert(#result == 3 and result[1] == 2 and result[2] == 3 and result[3] == 4) + print("test_slice passed") +end + +function test_index() + assert(index({1, 2, 3}, 2) == 2) + assert(index({1, 2, 3}, 4) == 0) + print("test_index passed") +end + +function test_key() + assert(key({a = 1, b = 2, c = 3}, 2) == "b") + assert(key({a = 1, b = 2, c = 3}, 4) == 0) + print("test_key passed") +end + +function test_concat() + local t1 = {1, 2} + local t2 = {3, 4} + concat(t1, t2) + assert(#t1 == 4 and t1[3] == 3 and t1[4] == 4) + print("test_concat passed") +end + +function test_contains() + assert(contains({1, 2, 3}, 2) == true) + assert(contains({1, 2, 3}, 4) == false) + print("test_contains passed") +end + +function test_reverse() + local result = reverse({1, 2, 3}) + assert(#result == 3 and result[1] == 3 and result[2] == 2 and result[3] == 1) + print("test_reverse passed") +end + +function test_serialize() + local result = serialize({a = 1, b = {c = 2}}) + assert(result:replace("\n", "") == '{ ["a"] = 1, ["b"] = { ["c"] = 2, }, }') + print("test_serialize passed") +end + +function test_deep_copy() + local original = {a = 1, b = {c = 2}} + local copy = deep_copy(original) + assert(copy.b.c == 2) + copy.b.c = 3 + assert(original.b.c == 2) + print("test_deep_copy passed") +end + +function test_round() + assert(round(1.2345, 2) == 1.23) + assert(round(1.2345, 0) == 1) + assert(round(-1.2345, 2) == -1.23) + print("test_round passed") +end + +function test_use() + local module = {test_var = 42} + use(module) + assert(test_var == 42) + print("test_use passed") +end + +function test_for_each() + local sum = 0 + for_each({1, 2, 3}, function(value) sum = sum + value end) + assert(sum == 6) + print("test_for_each passed") +end + +function test_map() + local result = map(function(x) return x * 2 end, {1, 2, 3}) + assert(#result == 3 and result[1] == 2 and result[2] == 4 and result[3] == 6) + print("test_map passed") +end + +function test_filter() + local result = filter(function(x) return x % 2 == 0 end, {1, 2, 3, 4}) + debug:log(#result) + assert(#result == 2 and result[2] == 2 and result[4] == 4) + print("test_filter passed") +end + +function test_skip() + local result = skip({1, 2, 3, 4}, 2) + assert(#result == 2 and result[1] == 3 and result[2] == 4) + print("test_skip passed") +end + +function test_take() + local result = take({1, 2, 3, 4}, 2) + assert(#result == 2 and result[1] == 1 and result[2] == 2) + print("test_take passed") +end + +function test_head() + assert(head({1, 2, 3}) == 1) + print("test_head passed") +end + +function test_tail() + local result = tail({1, 2, 3}) + assert(#result == 2 and result[1] == 2 and result[2] == 3) + print("test_tail passed") +end + +function test_foldr() + local result = foldr(operator.mul, 1, {1, 2, 3, 4, 5}) + assert(result == 120) + print("test_foldr passed") +end + +function test_reduce() + local result = reduce(operator.add, {1, 2, 3, 4}) + assert(result == 10) + print("test_reduce passed") +end + +function test_curry() + local function add(x, y) + return x + y + end + + local function multiply(x, y) + return x * y + end + + local curried_add = curry(add, function(...) return ... end) + local curried_multiply = curry(multiply, function(...) return ... end) + + assert(curried_add(3, 4) == 7) -- 3 + 4 = 7 + assert(curried_add(10, 20) == 30) -- 10 + 20 = 30 + + assert(curried_multiply(3, 4) == 12) -- 3 * 4 = 12 + assert(curried_multiply(10, 20) == 200) -- 10 * 20 = 200 + + print("test_curry passed") +end + +function test_bind1() + local mul5 = bind1(operator.mul, 5) + assert(mul5(10) == 50) + print("test_bind1 passed") +end + +function test_bind2() + local sub2 = bind2(operator.sub, 2) + assert(sub2(5) == 3) + print("test_bind2 passed") +end + +function test_is() + local is_table = is(type, "table") + assert(is_table({}) == true) + assert(is_table(42) == false) + print("test_is passed") +end + +function on_resume() + test_trim() + test_starts_with() + test_ends_with() + test_split() + test_replace() + test_slice() + test_index() + test_key() + test_concat() + test_contains() + test_reverse() + test_serialize() + test_deep_copy() + test_round() + test_use() + test_for_each() + test_map() + test_filter() + test_skip() + test_take() + test_head() + test_tail() + test_foldr() + test_reduce() + test_bind1() + test_bind2() + test_curry() + test_is() +end -- 2.43.0 From b2e60d725b99926dec1135e413af523812a9d0d5 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 27 May 2024 17:47:24 +0400 Subject: [PATCH 122/204] Update README --- CHANGELOG.md | 19 +++++++++++++++++++ README.md | 24 +++++------------------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 253a10f..b3cb41e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,22 @@ +### 5.2.3 + +* Added `on_load()` callback +* Added `on_resume_when_folding` meta tag + +### 5.2.1 + +* Added support for complex UIs +* Added `ui:set_progress()` function + +### 5.2.0 + +* Added `widgets` module to app widgets interaction + +### 5.1.0 + +* Added `add_purchase` action +* Added `on_contacts_loaded()` callback + ### 4.9.4 * The `aio:actions()` function now also returns arguments format for each action diff --git a/README.md b/README.md index e8d285c..134d361 100644 --- a/README.md +++ b/README.md @@ -25,31 +25,16 @@ The type of script is determined by the line (meta tag) at the beginning of the # Changelog +### 5.3.1 + +* Added `string:trim()`, `string:starts_with()` and `string:ends_with()` methods + ### 5.3.0 * Added `prefs:show_dialog` method * Added `system:show_notify()` and `system:cancel_notify()` methods * Added support for SVG icons to the Rich UI API -### 5.2.3 - -* Added `on_load()` callback -* Added `on_resume_when_folding` meta tag - -### 5.2.1 - -* Added support for complex UIs -* Added `ui:set_progress()` function - -### 5.2.0 - -* Added `widgets` module to app widgets interaction - -### 5.1.0 - -* Added `add_purchase` action -* Added `on_contacts_loaded()` callback - [Full changelog](CHANGELOG.md) # Widget scripts @@ -126,6 +111,7 @@ The list output functions support HTML and Markdown (see User Interface section ## User Interface _Available only in widget scripts._ +_AIO Launcher also offers a way to create more complex UIs: [instructions](README_RICH_UI.md)_ * `ui:show_text(string)` - displays plain text in widget, repeated call will erase previous text; * `ui:show_lines(table, [table], [folded_string])` - displays a list of lines with the sender (in the manner of a mail widget), the second argument (optional) - the corresponding senders (formatting in the style of a mail widget), folded\_string (optional) - string to be shown in folded mode; -- 2.43.0 From 7fdfecc9838b9d186bb47d6b2bcfa967241aff91 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 28 May 2024 10:13:45 +0400 Subject: [PATCH 123/204] Update counter widget to 2.0 --- community/counter-widget.lua | 120 +++++++++++++++++++++++++++++------ 1 file changed, 99 insertions(+), 21 deletions(-) diff --git a/community/counter-widget.lua b/community/counter-widget.lua index a5c97b5..eb52909 100644 --- a/community/counter-widget.lua +++ b/community/counter-widget.lua @@ -2,12 +2,14 @@ -- description = "Time counting widget to fight bad habits" -- type = "widget" -- author = "Evgeny Zobnin (zobnin@gmail.com)" --- arguments_help = "Enter the date of the start of counting in the format DD.MM.YYYY" --- version = "1.0" +-- version = "2.0" +-- on_resume_when_folding = "true" +local prefs = require "prefs" local date = require "date" -- constants +local max_counters = 5 local year = 365.25 local month = 30.43 @@ -18,48 +20,124 @@ local milestones = { } local milestones_formatted = { - "1 day", "3 days", "1 week", "2 weeks", - "1 months", "3 months", "6 months", - "1 year", "3 years", "5 years", "10 years", "20 years", "100 years" + "1+ days", "3+ days", "1+ weeks", "2+ weeks", + "1+ months", "3+ months", "6+ months", + "1+ years", "3+ years", "5+ years", "10+ years", "20+ years", "100+ years" } -function on_resume() - local args = settings:get() +function on_load() + init_default_settings() +end - if next(args) == nil then - ui:show_text("Tap to enter date") - return +function on_resume() + local gui_inst = {} + local lines_num = max_counters + + if ui:folding_flag() then + lines_num = 1 + end + + for i = 1, lines_num do + local title, start_date = parse_settings_string(i) + if title == nil then + break + end + + local curr_date = date() + local passed = date.diff(curr_date, start_date) + local passed_days = math.floor(passed:spandays()) + + local idx = get_milestone_idx(passed) + local passed_str = passed_days.." days" + if prefs.show_milestones then + passed_str = passed_str.." / "..milestones_formatted[idx] + end + local next_milestone_percent = passed_days / milestones[idx+1] * 100 + + table.insert(gui_inst, {"progress", title..": "..passed_str, {progress = next_milestone_percent}}) + end + + gui_inst = insert_between_elements(gui_inst, {"new_line", 1}) + gui(gui_inst):render() +end + +function init_default_settings() + if prefs.counter_1 == nil then + prefs["counter_1"] = "Sample / 31.01.2024" + for i = 2,max_counters do + prefs["counter_"..i] = "" + end + end + + if prefs.show_milestones == nil then + prefs.show_milestones = true + end +end + +function parse_settings_string(i) + local title_and_date = prefs["counter_"..i] + if title_and_date == nil or #title_and_date == 0 then + return nil + end + + local splitted = title_and_date:split("/") + + local title = trim(splitted[1]) + if title == nil or #title == 0 then + return nil + end + + local date_str = trim(splitted[2]) + if date_str == nil or #date_str == 0 then + return nil + end + + local arr = date_str:split("%.") + if arr == nil or #arr < 3 then + return nil end - local arr = args[1]:split("%.") local start_date = date(arr[3], arr[2], arr[1]) - local curr_date = date() - local passed = date.diff(curr_date, start_date) - local passed_days = math.floor(passed:spandays()) - local idx = get_milestone_idx(passed) - - ui:show_progress_bar(passed_days.." days / "..milestones_formatted[idx], - passed_days, milestones[idx]) + return title, start_date end function on_click() - settings:show_dialog() + prefs:show_dialog() end function on_settings() - settings:show_dialog() + prefs:show_dialog() end -- utils +function trim(s) + if s == nil or #s == 0 then return s end + return s:match("^%s*(.-)%s*$") +end + +function insert_between_elements(t, element) + local new_table = {} + for i = 1, #t do + table.insert(new_table, t[i]) + if i < #t then + table.insert(new_table, element) + end + end + return new_table +end + + function get_milestone_idx(passed) local days_passed = passed:spandays() - local idx = 1 + local idx = 0 for k,v in ipairs(milestones) do if days_passed > v then idx = idx + 1 + else + break end end -- 2.43.0 From 6ccc1593dc1822aac34a9ce9228aa10dbb286071 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 28 May 2024 10:14:03 +0400 Subject: [PATCH 124/204] Add TickTick widget --- community/ticktick-app-widget.lua | 109 ++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 community/ticktick-app-widget.lua diff --git a/community/ticktick-app-widget.lua b/community/ticktick-app-widget.lua new file mode 100644 index 0000000..6a7dff0 --- /dev/null +++ b/community/ticktick-app-widget.lua @@ -0,0 +1,109 @@ +-- name = "TickTick" +-- description = "AIO Launhcer wrapper for official TickTick app widget" +-- author = "Evgeny Zobnin (zobnin@gmail.com)" +-- uses_app = "com.ticktick.task" + +local prefs = require "prefs" +local fmt = require "fmt" + +local w_bridge = nil +local lines = {} + +function on_resume() + if not widgets:bound(prefs.wid) then + setup_app_widget() + end + + widgets:request_updates(prefs.wid) +end + +function on_app_widget_updated(bridge) + lines = {} + + -- We use dump_tree instead of dump_table because Lua tables + -- do not preserve the order of elements (which is important in this case). + -- Additionally, the text tree is simply easier to parse. + local tree = bridge:dump_tree() + local all_lines = extract_list_item_lines(tree) + lines = combine_lines(all_lines) + + table.insert(lines, "Add task") + + w_bridge = bridge + ui:show_lines(lines) +end + +function on_click(idx) + if idx == #lines then + -- "Plus" button + w_bridge:click("image_3") + else + -- First task name + w_bridge:click("text_2") + end +end + +function on_settings() + w_bridge:click("text_1") +end + +-- Extract all elements with a nesting level of 6 (task texts and dates) +function extract_list_item_lines(str) + for line in str:gmatch("[^\n]+") do + if line:match("^%s%s%s%s%s%s%s%s%s%s%s%s") then + table.insert(lines, extract_text_after_colon(line)) + end + end + return lines +end + +-- Tasks list elements in the the dump are separated by a 1x1 image, +-- so we can use it to understand where one task ends and another begins. +function combine_lines(lines) + local result = {} + local temp_lines = {} + + for i, line in ipairs(lines) do + if line == "1x1" then + if #temp_lines > 0 then + table.insert(result, concat_lines(temp_lines)) + temp_lines = {} + end + else + table.insert(temp_lines, line) + end + end + + if #temp_lines > 0 then + table.insert(result, concat_lines(temp_lines)) + end + + return result +end + +-- The text and date of a task in the dump appear consecutively, +-- and we need to combine them, keeping in mind that the date might be absent. +function concat_lines(lines) + if lines[1] then + lines[1] = fmt.primary(lines[1]) + end + + if lines[2] then + lines[2] = fmt.secondary(lines[2]) + end + + return table.concat(lines, fmt.secondary(" - ")) +end + +function extract_text_after_colon(text) + return text:match(":%s*(.*)") +end + +function setup_app_widget() + local id = widgets:setup("com.ticktick.task/com.ticktick.task.activity.widget.GoogleTaskAppWidgetProviderLarge") + if (id ~= nil) then + prefs.wid = id + else + ui:show_text("Can't add widget") + end +end -- 2.43.0 From 64128b5f66938f285019a18554dbd2cee604f473 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 2 Jul 2024 15:11:57 +0400 Subject: [PATCH 125/204] Update ticktcick widget --- community/ticktick-app-widget.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/community/ticktick-app-widget.lua b/community/ticktick-app-widget.lua index 6a7dff0..03670b7 100644 --- a/community/ticktick-app-widget.lua +++ b/community/ticktick-app-widget.lua @@ -1,6 +1,7 @@ -- name = "TickTick" -- description = "AIO Launhcer wrapper for official TickTick app widget" -- author = "Evgeny Zobnin (zobnin@gmail.com)" +-- version = "1.0" -- uses_app = "com.ticktick.task" local prefs = require "prefs" @@ -27,7 +28,7 @@ function on_app_widget_updated(bridge) local all_lines = extract_list_item_lines(tree) lines = combine_lines(all_lines) - table.insert(lines, "Add task") + table.insert(lines, fmt.secondary("Add task")) w_bridge = bridge ui:show_lines(lines) -- 2.43.0 From d63f93d39db74234ccffe4baa3264a2b2ad27103 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 5 Jul 2024 12:11:16 +0400 Subject: [PATCH 126/204] Move Quotes widget to defunct --- {main => defunct}/quotes-widget.lua | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {main => defunct}/quotes-widget.lua (100%) diff --git a/main/quotes-widget.lua b/defunct/quotes-widget.lua similarity index 100% rename from main/quotes-widget.lua rename to defunct/quotes-widget.lua -- 2.43.0 From c58dba3173c2cf98c6b43c66c60cd769f6c4ad22 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 5 Jul 2024 12:12:22 +0400 Subject: [PATCH 127/204] Update scripts zip --- scripts.index | 1 - scripts.md5 | 2 +- scripts.zip | Bin 18998 -> 18512 bytes 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts.index b/scripts.index index b3212d9..18008be 100644 --- a/scripts.index +++ b/scripts.index @@ -6,7 +6,6 @@ dice-widget.lua facts-widget.lua inspiration-quotes-widget.lua public-ip-widget.lua -quotes-widget.lua shell-widget.lua sunrise-sunset-widget.lua sys-info-widget.lua diff --git a/scripts.md5 b/scripts.md5 index a97470e..f030f41 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -4a21417c17c94f75078574e11a1e9d71 +82675d7d664ebf3f30c5f95a8b4f65e2 diff --git a/scripts.zip b/scripts.zip index 0a5b2d8705433fd11d35ee4927b507e155a05abd..6eb2937ead6af91ce2b5f0e58ca9e0ed23271241 100644 GIT binary patch delta 293 zcmdlsh4I1!#tD|pYIUI-Z4NSm=uJ#@oFIC0BX=zmn8C<58N!$@&<9qsSwmBse5A!_&y zD|x_D-M01+sk8PQAySQwB`lMD+~k-N#U|&tg)l!5XPDe0DKq)Ln*)=*^khZ%aHdBx zldIf=n0gf^pK}jmV%MIm<`Kd4O?PsGM+}pL{^WZeQA~TRCtG<&G5xchJk2wTd5b;6 bw)dHGr| delta 764 zcmcaGfpOau#tD|p{?iOL+8ksA(VLj+I6?I0M($cBFoThAGK4W*pbxBMvxd-22;+$G z38!49rty zBhSY4_{p2HGOTr`tL%S!e!uNprj=}otS?tDnk8Ld@jl|h@{=W8rd4l!wA(aQS~{Yl zb$Iv_RabqwW7%8Z`t*+5-;`InUQi2pXC(Di2A$+yzs?zH?Gu9P0%=Z0r;4+ukXUi`O9{%U(ekzpGE^_%$ zr}SIi)qB&q+Ey*zB-?jk%Ju3iOmTA-=B}K{;(4itr6>Ehdg6)qjLHj*m)`%la#P!d z^y#ygzGl(8|KaroJ)K9_jkcKnn$TO!e{{aKLh^g{uj%?XrW{(hB$i`yQK{JG_YdPI zCyJSaV{W!sDks9gQkO-5KT>}w0sZhxUmU7kp0EuP`Jy(dD2K`DN zu+$%Gdx(^s-A0JiC;Ji>OU(F|U;qJN^fN4JOcZ0l7W=Hg*q{8)S#ENgiyYGj@yTs2 zAx!y_lkd31GM$r|Z0#D(R46xjifa&)jMC&6u3=2mbS68vMKHDMPoCu#!+hR=VREd# z Date: Fri, 12 Jul 2024 09:11:32 +0400 Subject: [PATCH 128/204] Update Drawer Sample #4 --- samples/drawer-sample4.lua | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/samples/drawer-sample4.lua b/samples/drawer-sample4.lua index 7cdc30a..4836870 100644 --- a/samples/drawer-sample4.lua +++ b/samples/drawer-sample4.lua @@ -8,19 +8,10 @@ function on_drawer_open() end function on_icons_ready(icons) - names = map(pkgs, function(it) return apps:name(it) end) + names = map(function(it) return apps:name(it) end, pkgs) drawer:show_list(names, icons, nil, true) end function on_click(idx) apps:launch(pkgs[idx]) end - -function map(tbl, f) - local ret = {} - for k,v in pairs(tbl) do - ret[k] = f(v) - end - return ret -end - -- 2.43.0 From b5840ee5bb3d13e254e1281a3471949b1feefd51 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 12 Jul 2024 09:18:48 +0400 Subject: [PATCH 129/204] Add Ai module --- README.md | 28 +++++++++++++++++++++++++++- samples/ai-sample.lua | 7 +++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 samples/ai-sample.lua diff --git a/README.md b/README.md index 134d361..c864e7c 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,10 @@ The type of script is determined by the line (meta tag) at the beginning of the # Changelog +### 5.3.5 + +* Added `ai` module + ### 5.3.1 * Added `string:trim()`, `string:starts_with()` and `string:ends_with()` methods @@ -595,10 +599,32 @@ _Avaialble from: 4.1.0_ All data are returned in `on_cloud_result(meta, content)`. The first argument is the metadata, either a metadata table (in the case of `list_dir()`) or an error message string. The second argument is the contents of the file (in the case of `get_file()`). +## AI + +_Avaialble from: 5.3.5._ +_Requires subscription._ + +* `ai:complete(text)` - send message to the AI; +* `ai:translate(text, lang)` - translate text to the language with code `lang` (`en`, `de`, `es` etc). + +All functions return an answer in the callback `on_ai_answer`. For example: + +``` +function on_alarm() + ai:complete("Who are you?") +end + +function on_ai_answer(answer) + ui:show_text(answer) +end +``` + +_Keep in mind that the launcher imposes certain limitations on the use of this module. If you use it too frequently, you will receive an `error: rate limit` instead of a response. Additionally, an error will be returned if the request includes too much text._ + ## Reading notifications _Available only in widget scripts._ -_Avaialble from: 4.1.3_ +_Avaialble from: 4.1.3._ _This module is intended for reading notifications from other applications. To send notifications, use the `system` module._ diff --git a/samples/ai-sample.lua b/samples/ai-sample.lua new file mode 100644 index 0000000..da38092 --- /dev/null +++ b/samples/ai-sample.lua @@ -0,0 +1,7 @@ +function on_alarm() + ai:complete("Who are you?") +end + +function on_ai_answer(answer) + ui:show_text(answer) +end -- 2.43.0 From d063132df205495317970ed6d4558e26345b9be5 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 7 Aug 2024 20:44:11 +0400 Subject: [PATCH 130/204] Add profiles module docs and samples --- README.md | 10 ++++++++++ samples/profiles_sample1.lua | 13 +++++++++++++ samples/profiles_sample2.lua | 20 ++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 samples/profiles_sample1.lua create mode 100644 samples/profiles_sample2.lua diff --git a/README.md b/README.md index c864e7c..097d021 100644 --- a/README.md +++ b/README.md @@ -599,6 +599,16 @@ _Avaialble from: 4.1.0_ All data are returned in `on_cloud_result(meta, content)`. The first argument is the metadata, either a metadata table (in the case of `list_dir()`) or an error message string. The second argument is the contents of the file (in the case of `get_file()`). +## Profiles + +_Avaialble from: 5.3.6._ + +* `profiles:list()` - returns a list of saved profiles; +* `profiles:dump(name)` - saves a new profile with the specified name; +* `profiles:restore(name)` - restores the saved profile; +* `profiles:dump_json()` - creates a new profile but instead of saving it, returns it as a JSON string; +* `profiles:restore_json(json)` - restores a profile previously saved using `dump_json()`. + ## AI _Avaialble from: 5.3.5._ diff --git a/samples/profiles_sample1.lua b/samples/profiles_sample1.lua new file mode 100644 index 0000000..955db03 --- /dev/null +++ b/samples/profiles_sample1.lua @@ -0,0 +1,13 @@ +-- This sample lists current system profiles and allows to restore any of it + +profs = {} + +function on_resume() + profs = profiles:list() + ui:show_lines(profiles:list()) +end + +function on_click(idx) + ui:show_toast("Restoring...") + profiles:restore(profs[idx]) +end diff --git a/samples/profiles_sample2.lua b/samples/profiles_sample2.lua new file mode 100644 index 0000000..18634ad --- /dev/null +++ b/samples/profiles_sample2.lua @@ -0,0 +1,20 @@ +-- This script shows how to dump/restore profile without saving it to the system + +curr_profile = "" + +function on_resume() + ui:show_lines{ + "Dump profile", + "Restore profile" + } +end + +function on_click(idx) + if idx == 1 then + curr_profile = profiles:dump_json() + ui:show_toast("Saved") + else + ui:show_toast("Restoring...") + profiles:restore_json(curr_profile) + end +end -- 2.43.0 From 11a8cf2ad6ad9bbadecbb7217d285e4ef1a80ebb Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 12 Sep 2024 09:11:40 +0300 Subject: [PATCH 131/204] Move dev widgets to the dedicated folder --- dev/aioactionslist-widget.lua | 23 ++++++++++++++++++++++ dev/aiocolors-widget.lua | 23 ++++++++++++++++++++++ dev/aiowidgetslist-widget.lua | 23 ++++++++++++++++++++++ {samples => dev}/android-widget-dumper.lua | 0 {samples => dev}/fmt-test.lua | 0 {samples => dev}/mkd-test.lua | 0 env | 2 +- 7 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 dev/aioactionslist-widget.lua create mode 100644 dev/aiocolors-widget.lua create mode 100644 dev/aiowidgetslist-widget.lua rename {samples => dev}/android-widget-dumper.lua (100%) rename {samples => dev}/fmt-test.lua (100%) rename {samples => dev}/mkd-test.lua (100%) diff --git a/dev/aioactionslist-widget.lua b/dev/aioactionslist-widget.lua new file mode 100644 index 0000000..66c835c --- /dev/null +++ b/dev/aioactionslist-widget.lua @@ -0,0 +1,23 @@ +-- name = "AΙΟ actions list" +-- type = "widget" +-- description = "Shows actions returned by aio:actions() function" +--foldable = "true" +-- author = "Theodor Galanis" +-- version = "1" + +function on_resume() + actions = aio:actions() + local labels = "" + + labels = map(actions, function(it) return it.label end) + names = map(actions, function(it) return it.name end) + ui:show_lines(names, labels) + end + + function map(tbl, f) + local ret = {} + for k,v in pairs(tbl) do + ret[k] = f(v) + end + return ret + end \ No newline at end of file diff --git a/dev/aiocolors-widget.lua b/dev/aiocolors-widget.lua new file mode 100644 index 0000000..3a29164 --- /dev/null +++ b/dev/aiocolors-widget.lua @@ -0,0 +1,23 @@ +-- name = "AΙΟ colors" +-- type = "widget" +-- description = "Shows colors returned by aio:colors() function" +--foldable = "true" +-- author = "Theodor Galanis" +-- version = "1" + +function on_resume() + local colors = aio:colors() + local colors_strings = stringify_table(colors) + + ui:show_lines(colors_strings) +end + +function stringify_table(tab) + local new_tab = {} + + for k,v in pairs(tab) do + table.insert(new_tab, k..": "..tostring(v)) + end + + return new_tab +end \ No newline at end of file diff --git a/dev/aiowidgetslist-widget.lua b/dev/aiowidgetslist-widget.lua new file mode 100644 index 0000000..7df6121 --- /dev/null +++ b/dev/aiowidgetslist-widget.lua @@ -0,0 +1,23 @@ +-- name = "AΙΟ widgets list" +-- type = "widget" +-- description = "Shows widgets returned by aio:available_widgets() function" +--foldable = "true" +-- author = "Theodor Galanis" +-- version = "1" + +function on_resume() + actions = aio:available_widgets() + local labels = "" + + labels = map(actions, function(it) return it.label end) + names = map(actions, function(it) return it.name end) + ui:show_lines(names, labels) + end + + function map(tbl, f) + local ret = {} + for k,v in pairs(tbl) do + ret[k] = f(v) + end + return ret + end \ No newline at end of file diff --git a/samples/android-widget-dumper.lua b/dev/android-widget-dumper.lua similarity index 100% rename from samples/android-widget-dumper.lua rename to dev/android-widget-dumper.lua diff --git a/samples/fmt-test.lua b/dev/fmt-test.lua similarity index 100% rename from samples/fmt-test.lua rename to dev/fmt-test.lua diff --git a/samples/mkd-test.lua b/dev/mkd-test.lua similarity index 100% rename from samples/mkd-test.lua rename to dev/mkd-test.lua diff --git a/env b/env index aee4990..0dacf0b 100644 --- a/env +++ b/env @@ -1,3 +1,3 @@ -REPOS="main ru samples community" +REPOS="main ru samples community dev" SCRIPTS_DIR="/sdcard/Android/data/ru.execbit.aiolauncher/files/" -- 2.43.0 From 97947882df35421356ca2e05d3b7902ba879420c Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 12 Sep 2024 09:42:08 +0300 Subject: [PATCH 132/204] Subrise/Sunset widget: check location permission --- main/sunrise-sunset-widget.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/main/sunrise-sunset-widget.lua b/main/sunrise-sunset-widget.lua index b7a3fa9..4cf97e8 100644 --- a/main/sunrise-sunset-widget.lua +++ b/main/sunrise-sunset-widget.lua @@ -10,8 +10,16 @@ local json = require "json" local fmt = require "fmt" function on_alarm() - local location=system:location() - local url="https://api.sunrise-sunset.org/json?lat="..location[1].."&lng="..location[2].."&formatted=0" + local location = system:location() + + if location == nil then + return + elseif location == "permission_error" then + ui:show_text("No location permission") + return + end + + local url = "https://api.sunrise-sunset.org/json?lat=" .. location[1] .. "&lng=" .. location[2] .. "&formatted=0" http:get(url) end -- 2.43.0 From f7e5426ebe1692d6c564fc89b18b60f63cb75ac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Gombault?= Date: Thu, 19 Sep 2024 11:44:45 +0200 Subject: [PATCH 133/204] fix duplicate birthday entries --- community/birthdays-widget.lua | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/community/birthdays-widget.lua b/community/birthdays-widget.lua index 7dc90ea..2f5ed08 100644 --- a/community/birthdays-widget.lua +++ b/community/birthdays-widget.lua @@ -44,10 +44,19 @@ function redraw() events = {} local lines = {} for i,v in ipairs(contacts) do - table.insert(events, v) - table.insert(lines, fmt_line(v)) - if i == prefs.count then - break + local fmt_out = fmt_line(v) + local insert = 0 + if #lines == 0 then + insert = 1 + elseif not (fmt_out == lines[#lines]) then + insert = 1 + end + if insert == 1 then + table.insert(events, v) + table.insert(lines, fmt_out) + if #lines == prefs.count then + break + end end end ui:show_lines(lines) -- 2.43.0 From 1580867d3141c9ab8067134f831f9c581be2eb9d Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 21 Sep 2024 10:26:52 +0300 Subject: [PATCH 134/204] Update Google search widget --- community/google-search-app-widget.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/community/google-search-app-widget.lua b/community/google-search-app-widget.lua index 3822499..5b4c534 100644 --- a/community/google-search-app-widget.lua +++ b/community/google-search-app-widget.lua @@ -2,7 +2,7 @@ -- description = "AIO wrapper for the Google search app widget - open widget settings for options" -- type = "widget" -- author = "Theodor Galanis (t.me/TheodorGalanis)" --- version = "2.5" +-- version = "2.6" -- foldable = "false" -- uses_app: "com.google.android.googlequicksearchbox" @@ -50,10 +50,10 @@ elseif idx == indices[2] then elseif idx == indices[3] then w_bridge:click("image_7") elseif idx == indices[4] then - w_bridge:click("image_9") + w_bridge:click("image_11") elseif idx == indices[5] then - w_bridge:click("image_10") - else return + w_bridge:click("image_12") + else return end end @@ -70,7 +70,7 @@ ui:show_toast("Google weather") elseif idx == indices[3] then ui:show_toast("Google discover") elseif idx == indices[4] then - ui:show_toast("Google voice search") + ui:show_toast("Google voice search") elseif idx == indices[5] then ui:show_toast("Google Lens") end @@ -86,7 +86,7 @@ end function setup_app_widget() local id = widgets:setup("com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.SearchWidgetProvider") - + if (id ~= nil) then prefs.wid = id else @@ -125,4 +125,4 @@ tab.category = "MAIN" tab.package = "com.google.android.googlequicksearchbox" tab.component = "com.google.android.googlequicksearchbox/com.google.android.apps.search.weather.WeatherExportedActivity" return tab -end +end \ No newline at end of file -- 2.43.0 From d6e4e53da509086edaa6227cf875ad4f057c2c50 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 21 Sep 2024 10:27:33 +0300 Subject: [PATCH 135/204] Add Profile dumper and Profile save/restore widgets --- community/profiles-dumper-widget.lua | 16 ++++++++++ community/profiles-restore-save-widget.lua | 35 ++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 community/profiles-dumper-widget.lua create mode 100644 community/profiles-restore-save-widget.lua diff --git a/community/profiles-dumper-widget.lua b/community/profiles-dumper-widget.lua new file mode 100644 index 0000000..8f4e87f --- /dev/null +++ b/community/profiles-dumper-widget.lua @@ -0,0 +1,16 @@ +-- name = "Profiles auto dumper" +-- description = "Hidden widget that auto dump profile on every return to the home screen" +-- type = "widget" +-- author = "Evgeny Zobnin (zobnin@gmail.com)" +-- version = "1.0" +-- foldable = "false" + +local prof_name = "Auto dumped" + +function on_load() + ui:hide_widget() +end + +function on_resume() + profiles:dump(prof_name) +end diff --git a/community/profiles-restore-save-widget.lua b/community/profiles-restore-save-widget.lua new file mode 100644 index 0000000..f4c0c33 --- /dev/null +++ b/community/profiles-restore-save-widget.lua @@ -0,0 +1,35 @@ +-- name = "Profile Switcher" +-- version = "1.0" +-- description = "Tap: restore profile / Long-press: save to profile" +-- type = "widget" +-- author = "Marcus Johansson" + +local profs +local profile + +function on_load() + profs = profiles:list() + ui:show_buttons(profs) +end + +function on_click(idx) + profile = profs[idx] + profiles:restore(profile) + ui:show_toast(profile..": Restored") +end + +function on_long_click(idx) + profile = profs[idx] + title = 'Save to "'..profile..'" ?' + text = 'Do you want to save the current screen state to the "'..profile..'" profile ?' + ui:show_dialog(title, text, "Yes", "Cancel") +end + +function on_dialog_action(value) + if value == 1 then + profiles:dump(profile) + ui:show_toast(profile..": Saved") + elseif value == 2 then + ui:show_toast("Canceled") + end +end \ No newline at end of file -- 2.43.0 From 7f3fac9034f2bbfd249838900c54dcd2680d1190 Mon Sep 17 00:00:00 2001 From: meluskyc Date: Sat, 26 Oct 2024 19:53:12 -0400 Subject: [PATCH 136/204] Add calendar progress widget --- community/calendar-progress-widget.lua | 89 ++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 community/calendar-progress-widget.lua diff --git a/community/calendar-progress-widget.lua b/community/calendar-progress-widget.lua new file mode 100644 index 0000000..84bb0e6 --- /dev/null +++ b/community/calendar-progress-widget.lua @@ -0,0 +1,89 @@ +-- name = "Calendar Progress" +-- description = "Shows day, week, month, and year progress bars" +-- type = "widget" +-- author = "meluskyc" +-- version = "1.0" +-- foldable = "false" + +local prefs = require "prefs" + +function on_load() + prefs.show_day = true + prefs.show_week = true + prefs.show_month = true + prefs.show_year = true +end + +function on_resume() + local now = os.date("*t", os.time()) + local gui_elems = {} + + if prefs.show_day then + local seconds_since_day_start = + now.sec + -- current minute + now.min * 60 + -- previous minutes + now.hour * 3600 -- previous hours + local progress_percentage = math.floor((seconds_since_day_start / (24 * 60 * 60)) * 100) + local label = "Day: " .. progress_percentage .. "%" + table.insert(gui_elems, {"progress", label, {progress = progress_percentage}}) + + if prefs.show_week or prefs.show_month or prefs.show_year then + table.insert(gui_elems, {"new_line", 1}) + end + end + + if prefs.show_week then + local seconds_since_week_start = + now.sec + -- current minute + now.min * 60 + -- previous minutes + now.hour * 3600 + -- previous hours + (now.wday - 1) * 86400 -- previous days + local progress_percentage = math.floor((seconds_since_week_start / (7 * 24 * 60 * 60)) * 100) + local label = "Week: " .. progress_percentage .. "%" + table.insert(gui_elems, {"progress", label, {progress = progress_percentage}}) + + if prefs.show_month or prefs.show_year then + table.insert(gui_elems, {"new_line", 1}) + end + end + + if prefs.show_month then + local days_in_month = os.date("*t", os.time{year=now.year, month=now.month+1, day=0}).day + local seconds_since_month_start = + now.sec + -- current minute + now.min * 60 + -- previous minutes + now.hour * 3600 + -- previous hours + (now.day - 1) * 86400 -- previous days + local progress_percentage = math.floor((seconds_since_month_start / (days_in_month * 24 * 60 * 60)) * 100) + local label = "Month: " .. progress_percentage .. "%" + table.insert(gui_elems, {"progress", label, {progress = progress_percentage}}) + + if prefs.show_year then + table.insert(gui_elems, {"new_line", 1}) + end + end + + if prefs.show_year then + local seconds_since_year_start = + now.sec + -- current minute + now.min * 60 + -- previous minutes + now.hour * 3600 + -- previous hours + (now.yday - 1) * 86400 -- previous days + + -- check for leap year + local days_in_year = 365 + if (now.year % 4 == 0 and now.year % 100 ~= 0) or (now.year % 400 == 0) then + days_in_year = 366 + end + + local progress_percentage = math.floor((seconds_since_year_start / (days_in_year * 24 * 60 * 60)) * 100) + local label = "Year: " .. progress_percentage .. "%" + table.insert(gui_elems, {"progress", label, {progress = progress_percentage}}) + end + + gui(gui_elems).render() +end + +function on_settings() + prefs:show_dialog() +end -- 2.43.0 From c12341915f22e3e166a9081aefb51e8d761d48e8 Mon Sep 17 00:00:00 2001 From: Hannu Hartikainen Date: Mon, 28 Oct 2024 13:07:06 +0200 Subject: [PATCH 137/204] Electricity spot price widget v1.1 The API used has changed the unit string. Update script to match. Also since the defaults are for Finland, update VAT percentage as it changed last month. --- community/electricity-price-widget.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/community/electricity-price-widget.lua b/community/electricity-price-widget.lua index 023c1e7..0945acf 100644 --- a/community/electricity-price-widget.lua +++ b/community/electricity-price-widget.lua @@ -4,7 +4,7 @@ -- type = "widget" -- foldable = "true" -- author = "Hannu Hartikainen " --- version = "1.0" +-- version = "1.1" json = require "json" prefs = require "prefs" @@ -28,7 +28,7 @@ function on_load() -- VAT percentage if not prefs.vat_percentage then - prefs.vat_percentage = 24 + prefs.vat_percentage = 25.5 end -- change threshold percentages for showing changes in folded format @@ -88,7 +88,7 @@ function parse_result(result) end price_interval = price_data.unix_seconds[2] - price_data.unix_seconds[1] - if price_data.unit == "EUR/MWh" then + if price_data.unit == "EUR/MWh" or price_data.unit == "EUR / megawatt_hour" then price_unit = "c/kWh" unit_multiplier = 0.1 else -- 2.43.0 From 98afb5708e2bf78ed61e2efec20872ab1fb96dbf Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 31 Oct 2024 10:05:43 +0700 Subject: [PATCH 138/204] Add aio:add_todo() method --- README.md | 7 ++++++- samples/add_todo_sample.lua | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 samples/add_todo_sample.lua diff --git a/README.md b/README.md index 097d021..cd758e5 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,10 @@ The type of script is determined by the line (meta tag) at the beginning of the # Changelog +### 5.5.0 + +* Added `aio:add_todo()` method + ### 5.3.5 * Added `ai` module @@ -351,7 +355,8 @@ Intent table format (all fields are optional): * `aio:do_action(string)` - performs an AIO action ([more](https://aiolauncher.app/api.html)); * `aio:actions()` - returns a list of available actions; * `aio:settings()` - returns a list of available AIO Settings sections; -* `aio:open_settings([section])` - open AIO Settings or AIO Settings section. +* `aio:open_settings([section])` - open AIO Settings or AIO Settings section; +* `aio:add_todo(icon, text)` - add a TODO item with the specified Fontawesome icon and text. Format of table elements returned by `aio:available_widgets()`: diff --git a/samples/add_todo_sample.lua b/samples/add_todo_sample.lua new file mode 100644 index 0000000..8403781 --- /dev/null +++ b/samples/add_todo_sample.lua @@ -0,0 +1,17 @@ +function on_resume() + ui:show_lines{ + "Add todo #1", + "Add todo #2", + "Add todo #3", + } +end + +function on_click(idx) + if idx == 1 then + aio:add_todo("face-smile", "Todo #1") + elseif idx == 2 then + aio:add_todo("face-smile-tongue", "Todo #2") + else + aio:add_todo("face-smile-tear", "Todo #3") + end +end -- 2.43.0 From 58d4d41ab3837155fda4ed9a4af4d4db50abbdc9 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 31 Oct 2024 20:03:38 +0700 Subject: [PATCH 139/204] Fix spelling --- main/facts-widget.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/facts-widget.lua b/main/facts-widget.lua index 10da273..396c493 100644 --- a/main/facts-widget.lua +++ b/main/facts-widget.lua @@ -1,5 +1,5 @@ -- name = "Random facts" --- description = "Radom useless facts" +-- description = "Random useless facts" -- data_source = "https://uselessfacts.jsph.pl/" -- type = "widget" -- author = "Evgeny Zobnin (zobnin@gmail.com)" -- 2.43.0 From 91f733c882d28d724e6373aab011b9d9cf82e862 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 31 Oct 2024 20:09:41 +0700 Subject: [PATCH 140/204] Update scripts zip --- scripts.md5 | 2 +- scripts.zip | Bin 18512 -> 18554 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts.md5 b/scripts.md5 index f030f41..09b5ec2 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -82675d7d664ebf3f30c5f95a8b4f65e2 +fc3cd3e27dc344ab709af0c80a311d44 diff --git a/scripts.zip b/scripts.zip index 6eb2937ead6af91ce2b5f0e58ca9e0ed23271241..9dd939c4228f5ea120595ac552011c9c79e3d1a5 100644 GIT binary patch delta 1942 zcmZ9Nc{r4N8^@n#EGJ7$#vn5qTP0&_v1A*@m@y#}MkdR##4yRJL6l{LqLAeg*~*qf z5$D*#$st>$H^!1PN$5QyujQp8={S$Zb)C!k2MX7t`SD7%@8pSO;-;Z)=1E z69M~KNOk`H9i#`y2`KoHp)DUnw*Uda0RaF=01NnfdItw-hWejn`UGnQgm}^&MF0V8 zvWE)oG``j;QexgbezU9oxw}WV8*P^`SNMnhr3$(A zOq>Y4j>V1mC1CTfZ^xfUcSO^O8|r0;1!{?$UlWTpVukZ-S!aD_UPZ9W1{&WQwiU5` ze?7AHv9B1fmz$_FvmA^08Znex-MS)|!5j{LR=EGbLh`2_*&(TlK=qdA~Zce$hzVV>HhbYdKFkGJ$yzCv(Y)yDM`kp_6U+1vhd%C5zk7 zfn^-0Uqp`)9VnP+;u z*_PtVi&9pzE(i3Dx(ZW$^YD66=PQz{ZKbC4xtLAdKjpP?g>Ik>_yy`jF+q?CX`;3H z+5;^Pf|<~H89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B^c}+x8zx-=BImyhu>eE^^h0#^Jm6EtD4Vghz)g$La^g%MR3{c|5BI-`plQixYQ-NYrC` zw)7zXv|Tt0rW;cgZB=cYh9CjZ&}5T>*(O3P>YTkKh4D7OBJI>bnQpVvmT5Mf7$g!> zsE!JKG*t&df?$T-W(C*Tad3z?{IBZ@Z*;?9&~>NnE1agOiF5PdcP zKoLm47U}|6s!M`;EDO|DTv$ZJ9P(LirXotPy{M2wLsdV2dIbJ=Qxv?!ayDP>G5{E@ z3Or2!@Gk;URT*GEdJl|X8k>cqzrw5=lLVnrkD*a@SM6Xx0oxV5 Date: Mon, 11 Nov 2024 08:54:52 +0700 Subject: [PATCH 141/204] Add Perplexity search script --- samples/perplexity-search.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 samples/perplexity-search.lua diff --git a/samples/perplexity-search.lua b/samples/perplexity-search.lua new file mode 100644 index 0000000..f466062 --- /dev/null +++ b/samples/perplexity-search.lua @@ -0,0 +1,26 @@ +-- name = "Ask Perplexity AI" +-- description = "search what you want with perplexity" +-- data_source = "internal" +-- type = "search" +-- author = "JohnyWater" +-- version = "1.0" +-- prefix = "ask" + +text_from = "" +text_to = "" + +local urll = require "url" +local md_color = require "md_colors" +local green = md_colors.green_400 + +function on_search(input) + text_from = input + text_to = "" + search:show({input},{green}) +end + +function on_click(idx) + system:open_browser( + "https://www.perplexity.ai/?q=" .. urll.quote(text_from) + ) +end -- 2.43.0 From e828444426fb846b023c09237ea506f58457fc7d Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 11 Nov 2024 08:58:20 +0700 Subject: [PATCH 142/204] Add calendar:is_holiday() --- README.md | 9 +++++++-- samples/is-holiday-widget.lua | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 samples/is-holiday-widget.lua diff --git a/README.md b/README.md index cd758e5..1487859 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,10 @@ The type of script is determined by the line (meta tag) at the beginning of the # Changelog +### 5.5.1 + +* Added `calendar:is_holiday()` method + ### 5.5.0 * Added `aio:add_todo()` method @@ -472,12 +476,13 @@ If there is a problem with the network, the `on_network_error_$id` callback will ## Calendar * `calendar:events([start_date], [end_date], [cal_table])` - returns table of event tables of all calendars, start\_date - event start date, end\_date - event end date, cal\_table - calendar ID table (function will return the string `permission_error` if the launcher does not have permissions to read the calendar); -* `calendar:request_permission()` - requests access rights to the calendar; * `calendar:calendars()` - returns table of calendars tables; +* `calendar:request_permission()` - requests access rights to the calendar; * `calendar:show_event_dialog(id)` - shows the event dialog; * `calendar:open_event(id|event_table)` - opens an event in the system calendar; * `calendar:open_new_event([start], [end])` - opens a new event in the calendar, `start` - start date of the event in seconds, `end` - end date of the event; -* `calendar:add_event(event_table)` - adds event to the system calendar. +* `calendar:add_event(event_table)` - adds event to the system calendar; +* `calendar:id_holiday(date)` - returns true if the given date is a holiday or a weekend. Event table format: diff --git a/samples/is-holiday-widget.lua b/samples/is-holiday-widget.lua new file mode 100644 index 0000000..923a12e --- /dev/null +++ b/samples/is-holiday-widget.lua @@ -0,0 +1,5 @@ +function on_resume() + local unix_time = 1735698800 // 01.01.2025 + local date_str = os.date("%d.%m.%Y", unix_time) + ui:show_text(date_str.." is holiday: "..tostring(calendar:is_holiday(unix_time))) +end -- 2.43.0 From f3100ec22c3eb3e29cd0984a6676b72d81617177 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 11 Nov 2024 09:05:19 +0700 Subject: [PATCH 143/204] Update Monthly Calendar --- main/calendar.lua | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/main/calendar.lua b/main/calendar.lua index e0a6efa..83e2cee 100644 --- a/main/calendar.lua +++ b/main/calendar.lua @@ -2,7 +2,7 @@ -- description = "Monthly calendar with system calendar events" -- type = "widget" -- author = "Andrey Gavrilov" --- version = "3.1" +-- version = "3.2" local tab = {} local line = " " @@ -15,15 +15,6 @@ local month = os.date("%m"):gsub("^0","") local day = os.date("%d"):gsub("^0","") function on_resume() - if widget_type == "text" then - return - end - --ui:set_folding_flag(true) - ui:show_table(table_to_tables(tab,8),0, true, line) - widget_type = "table" -end - -function on_alarm() if calendar:events(0,0) == "permission_error" then widget_type = "text" ui:show_text("Click to grant permission") @@ -51,13 +42,13 @@ function on_click(i) local time = os.time{year=year,month=month,day=1}-24*60*60 year,month = os.date("%Y-%m",time):match("(%d+)-(%d+)") year,month = year:gsub("^0",""),month:gsub("^0","") - on_alarm() + on_resume() elseif i == 8 then system:vibrate(10) local time = os.time{year=year,month=month,day=1}+31*24*60*60 year,month = os.date("%Y-%m",time):match("(%d+)-(%d+)") year,month = year:gsub("^0",""),month:gsub("^0","") - on_alarm() + on_resume() elseif i > 1 and i < 8 then dialog_id = "date" ui:show_edit_dialog("Enter month and year", "Format - 12.2020. Empty value - current month", string.format("%02d.%04d", month, year)) @@ -86,7 +77,7 @@ function on_click(i) end function on_permission_granted() - on_alarm() + on_resume() end function on_dialog_action(data) @@ -104,7 +95,7 @@ function on_dialog_action(data) return end year,month = y,m - on_alarm() + on_resume() return elseif not check_date(data) then return @@ -117,10 +108,10 @@ function on_dialog_action(data) end month,year = data:match("(%d+)%.(%d+)") month,year = month:gsub("^0",""),year:gsub("^0","") - on_alarm() + on_resume() elseif dialog_id == "settings" then settings:set(id_to_cal_id(data)) - on_alarm() + on_resume() end end @@ -177,7 +168,7 @@ function format_day(y,m,d,events) end if year == os.date("%Y"):gsub("^0","") and month == os.date("%m"):gsub("^0","") and d == os.date("%d"):gsub("^0","") then dd = ""..dd.."" - elseif os.date("%w",from):gsub("0","7")-5 > 0 then + elseif calendar:is_holiday(os.time{year=y,month=m,day=d}) then dd = ""..dd.."" else dd = ""..dd.."" -- 2.43.0 From d1f1be14a112e3421cdb1ebe96ada2df5a963e0a Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 11 Nov 2024 09:05:37 +0700 Subject: [PATCH 144/204] Update scripts zip --- scripts.md5 | 2 +- scripts.zip | Bin 18554 -> 18529 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts.md5 b/scripts.md5 index 09b5ec2..e299774 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -fc3cd3e27dc344ab709af0c80a311d44 +98801fcd46367f49a67aca3c2189b868 diff --git a/scripts.zip b/scripts.zip index 9dd939c4228f5ea120595ac552011c9c79e3d1a5..c818b20162a224b982e40cd5c784cb2f6c288c57 100644 GIT binary patch delta 2731 zcmY+Gc{G#_8^&jbWSJqPCR>QHlYL*aOxeqtt(h#z+L%d%hmllM^m?*nnUF1!SC*2- zPGk#N6Q=Alwrpj@*PFk-`<(kazjIypx&OX)A492+p^vqgYQ2>zbkm`7vS@#omdr6_ zAvOpkLkt3eLj)mLF#+B|UKpH000HA*&jw+_c`Nz;*<{#pKtO{BNYy{m)cE#m`ZyYg zvx0XSx>kiLE_U%r!JH&ZtE)_J9sIoML}QI5)o&KqM9HnJ*Sj#z2l=2^a0lobP%y+O zhn}o56XNqT^K|V~OJ{ymvOE&VESN=2R+P6m7uuz7ta~+!xs-+yTubB#-os{hzrMh= zJaD)BnC}NXNwMrAZgzc@M?@Fp`MX@a^j2QOCGnAGp`Ah)Js6YnQuAf;o8)i|N{4MO zQa4crnU+G8P>p)4QC@Mu&$-6tiKQel0q-@X9l;L?mJ!p^(F8Q0JvuodVRv zX;?T1&+N`A-)`jh-Dt3;Dqh!6 zUVfw=D#&bIX}qDd|VI$5+Wl{jPP2h*Z7} z>;tuR6anDE|sCQwG1T_0>T+z?A zVcNFBxvn_#wY#$Q&;rR!A%0f2QXd6*)ZdD!g|y*?kC+dpapV2W2Rii2+G4CJa2qS1 z{eJ)LL84VBYsVBvb!(UuQ%?!&4Z<^ku&NclU7A1<@fbl+7-6gu%#NKw-iB}PA8B_H z@a488{k(Q3F7mm8hsZI$nMqEfOMomLja3-s3)o?ynDI+?A_5z(RNk--3#PGUQxN1) zX8#vh8;a)o*ceey#p1N((WNtSG@krQ*q6Y|3s8mebBc;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jj$x&It{FQT;Uag1ZPjX03> zM91OOrvC|8upSD>sLKRWW7YjDAv6MEcFW zuYP9`6cNC_f-li%Ky9)Efg-K;hrtYzqkr`P>mxle(NW*M3)b*a;kB=m5W`y6-i8gl z+9O!I<`(J(bSy9I7Dh@AHw5QtjR9k)qD~4RgI{DQ6F_Qiugf5njG5WlE#%Sc@}C>8 zsz#1pZ}nr{W5pf)TxnS4ShtaNeW$08U7L2G>()aNjI~zdW2j#MM~Nsl96`H z-uO^qROaiJD<}<9{ci!Q^Mysx{efi`@ED@mlA-i`F~W6c&OUZ1MEL1H%2sOQ_-C|?!EsHhY&i2D#iFTwtjv%#$BJHu znU3}U8zIQACkjP_zw`w_71&vp^N{}z^!F{kV+h9R*+RR)vER`Jl+m|_eg*&1x1o>Z zfPer80zA~$fnESLQ4Ua7@FB_uN(0wXE>J9JVqj0l%nz0rSV9}XeFHnF9B6Ln07Zc1 shR*bUvJfy(mK&V7A_R_U{J-HM=y}BnDh|H>9cdt+k@ksB-T%h<7pF%gWdHyG -- 2.43.0 From d93c42b50afdf5a1fbad24dba558939756cca96d Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 11 Nov 2024 09:51:35 +0700 Subject: [PATCH 145/204] Fix Weekly Calendar backward compatibility --- main/calendar.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/calendar.lua b/main/calendar.lua index 83e2cee..893a751 100644 --- a/main/calendar.lua +++ b/main/calendar.lua @@ -168,7 +168,7 @@ function format_day(y,m,d,events) end if year == os.date("%Y"):gsub("^0","") and month == os.date("%m"):gsub("^0","") and d == os.date("%d"):gsub("^0","") then dd = ""..dd.."" - elseif calendar:is_holiday(os.time{year=y,month=m,day=d}) then + elseif calendar.is_holiday and calendar:is_holiday(os.time{year=y,month=m,day=d}) then dd = ""..dd.."" else dd = ""..dd.."" -- 2.43.0 From dbb0608176bac5a1f71852bcd73159681d93fc9c Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 11 Nov 2024 09:51:48 +0700 Subject: [PATCH 146/204] Update scripts zip --- scripts.md5 | 2 +- scripts.zip | Bin 18529 -> 18537 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts.md5 b/scripts.md5 index e299774..a8bec8d 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -98801fcd46367f49a67aca3c2189b868 +b8a11f997ee3311bc357719223dd89b9 diff --git a/scripts.zip b/scripts.zip index c818b20162a224b982e40cd5c784cb2f6c288c57..850779ec9407ac41ca9f308848562bd04b8999bd 100644 GIT binary patch delta 2579 zcmV+u3hedakOAqC0kG5o4OLESSzS&yvLy)s0J4+e0T>1WaWQ8Bag+Z66@T0|5`W(P z6odlfq?oJhu9ItGcn!2gd-syQT!A8R_ZISs_7c_~pQM$u2we1~FMaA`agX=S+D~#b zLsB9o?b=Rqzy-lZB4^0q%BGH#O=L#HGEXbjiK560k5wCyksAK#E>pY**PG6* zJS{i*-3nWM@9RXaZ&;PH>mtf3)(-3ijYc7=ZJ|a7bH*dEEJNi|RF%xG%Tt)l56H4i zCd!o2sOg0VAI*u9WPb%KD*fPMz6{1A8cPKhyP?a+5O8uY^y?sFA3lOxMvd(lIG=u3 zRjyu3eCMwNKIN<`wt`cZXeIQ9tUw1|VsRC16Vnicp~rkL3~?R`6V1=j6zmJY5u@R} z!38++GfPHOo%}N$Ub}?#Myzix^Y<$y2$8^sCgi2ZS;uK7OMebeFd{Bl#$ERZeS6jz zTwewhGG`6VB22VEKw|UEG>p`)KCR_tfnJ$S18mjXQ4(fAV&l^X^wpw`-9mW~l7BI~ zpUhuA|LYX~qIN6eZnO#PAdW)?r)gBJH@@c|#mB*fe!ZZliZAX)QeB@A*NMWsUV72S7Uo?^|Z9_B5Lqq zFGUJ+@d-_vG^lFx6#dpvls2}e%33iod(?`l8Qp8M->{BK*pTzQ@+?H#@wAUe2cU?= zcU=JLZzZs3w;*h!?U^nVIJTRj$y}Y$9hBo~AAiDnD3Ik9qspmDHMzQ(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, 14 Nov 2024 16:58:40 +0700 Subject: [PATCH 147/204] Update README --- README.md | 34 ++++++++++++++++++++++++++++++---- README_RICH_UI.md | 2 +- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1487859..9b44b72 100644 --- a/README.md +++ b/README.md @@ -275,16 +275,36 @@ The function takes a command table of this format as a parameter: `traffic` - traffic progress bar; `screen` - screen time progress bar; `alarm` - next alarm info; +`clock` - current time; `notes [NUM]` - last NUM notes; `tasks [NUM]` - last NUM tasks; `calendar [NUM]` - last NUM calendar events; +`calendarw` - weekly calendar; `exchage [NUM] [FROM] [TO]` - exchange rate FROM currency TO currency; `player` - player controls; -`health` - health data; `weather [NUM]` - weather forecast for NUM days; `worldclock [TIME_ZONE]` - time in the given TIME_ZONE; `notify [NUM]` - last NUM notifications; `dialogs [NUM]` - last NUM dialogs; +`calculator` - calculator; +`feed [NUM]` - news feed; +`control` - control panel; +`stopwatch` - stopwatch; +`finance [NUM]` - finance tickers; +`financechart` - finance chart; +`contacts [NUM]` - contacts (number of lines); +`apps [NUM]` - frequent apps (number of lines); +`appbox [NUM]` - my apps (number of lines); +`applist [NUM]` - apps list (number of lines); +`appfolders [NUM]` - app folders; +`timer` - timers; +`mailbox [NUM]` - mail widget; +`dialer` - dialer; +`recorder` - recorder; +`telegram` - telegram messages; +`smartspacer` - SmartSpacer; +`widgetscontainer` - widgets container; +`tips` - tips; `text [TEXT]` - just shows TEXT; `space [NUM]` - NUM of spaces. ``` @@ -482,7 +502,7 @@ If there is a problem with the network, the `on_network_error_$id` callback will * `calendar:open_event(id|event_table)` - opens an event in the system calendar; * `calendar:open_new_event([start], [end])` - opens a new event in the calendar, `start` - start date of the event in seconds, `end` - end date of the event; * `calendar:add_event(event_table)` - adds event to the system calendar; -* `calendar:id_holiday(date)` - returns true if the given date is a holiday or a weekend. +* `calendar:is_holiday(date)` - returns true if the given date is a holiday or a weekend. Event table format: @@ -730,9 +750,15 @@ function on_resume() end ``` -The `new_key` will be present in the table even after the AIO Launcher has been restrated. +The `new_key` will be present in the table even after the AIO Launcher has been restarted. -The `show_dialog()` method automatically creates a window of current settings from fields defined in prefs. The window will display all fields with a text key and a value of one of three types: string, number, or boolean. All other fields of different types will be omittedi. Fields whose names start with an underscore will also be omitted. Script will be reloaded on settings save. +The `show_dialog()` method automatically creates a window of current settings from fields defined in prefs. The window will display all fields with a text key and a value of one of three types: string, number, or boolean. All other fields of different types will be omitted. Fields whose names start with an underscore will also be omitted. Script will be reloaded on settings save. + +Starting from version 5.5.2, you can change the order of fields in the dialog by simply specifying the order in `prefs._dialog_order`. For example: + +``` +prefs._dialog_order = "message,start_time,end_time" +``` ## Animation and real time updates diff --git a/README_RICH_UI.md b/README_RICH_UI.md index 41fb90c..52dbae1 100644 --- a/README_RICH_UI.md +++ b/README_RICH_UI.md @@ -1,6 +1,6 @@ Starting with version 5.2.1, AIO Launcher includes an API that allows for displaying a more complex interface than what the high-level functions of the `ui` module allowed. For example, you can display text of any size, center it, move it up and down, display buttons on the left and right sides of the screen, draw icons of different sizes, and much more. Essentially, you can replicate the appearance of any built-in AIO widget. -Open the example [samples/rich-gui-basic-sample.lua] and study it. As you can see, the new API consists of just one function `gui`, which takes a table describing the UI as input and returns an object that has a `render()` method for drawing this UI. +Open the example [rich-gui-basic-sample.lua](samples/rich-gui-basic-sample.lua) and study it. As you can see, the new API consists of just one function `gui`, which takes a table describing the UI as input and returns an object that has a `render()` method for drawing this UI. The UI is built line by line, using commands that add elements from left to right, with the possibility of moving to a new line. The provided example displays two lines, under which are two buttons: -- 2.43.0 From a4960a9b608987ecf6a623e7b6ff65cc662adfe3 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 15 Nov 2024 13:10:11 +0700 Subject: [PATCH 148/204] Add Timed message widget --- README.md | 2 -- community/timed-message-widget.lua | 58 ++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 community/timed-message-widget.lua diff --git a/README.md b/README.md index 9b44b72..a074d14 100644 --- a/README.md +++ b/README.md @@ -867,8 +867,6 @@ In order for AIO Launcher to correctly display information about the script in t -- name = "Covid info" -- description = "Cases of illness and death from covid" -- data_source = "https://covid19api.com" --- arguments_help = "Specify the country code" --- arguments_default = "RU" -- type = "widget" -- foldable = "false" -- author = "Evgeny Zobnin (zobnin@gmail.com)" diff --git a/community/timed-message-widget.lua b/community/timed-message-widget.lua new file mode 100644 index 0000000..7454e3d --- /dev/null +++ b/community/timed-message-widget.lua @@ -0,0 +1,58 @@ +-- name = "Timed message" +-- description = "A message that is displayed at a specific time" +-- type = "widget" +-- foldable = "false" +-- author = "Evgeny Zobnin (zobnin@gmail.com)" +-- version = "1.0" + +local prefs = require "prefs" + +function on_load() + prefs._dialog_order = "message,start_time,end_time" + + if not prefs.message then + prefs.message = "Sample message" + end + + if not prefs.start_time then + prefs.start_time = "09:00" + end + + if not prefs.end_time then + prefs.end_time = "10:00" + end +end + +function on_resume() + ui:show_text(prefs.message) + hide_or_show() +end + +function on_settings() + prefs:show_dialog() +end + +function hide_or_show() + local start_time = convert_to_unix_time(prefs.start_time) + local end_time = convert_to_unix_time(prefs.end_time) + local current_time = os.time() + + if current_time > start_time and current_time < end_time then + ui:show_widget() + else + ui:hide_widget() + end +end + +function convert_to_unix_time(time_str) + local hour, minute = time_str:match("^(%d%d):(%d%d)$") + hour, minute = tonumber(hour), tonumber(minute) + + local current_date = os.date("*t") + + current_date.hour = hour + current_date.min = minute + current_date.sec = 0 + + return os.time(current_date) +end -- 2.43.0 From 41ab2191be333be852a07623054fd8bd90883c0d Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 15 Nov 2024 13:13:08 +0700 Subject: [PATCH 149/204] Add Alquran script --- community/alquran-widget.lua | 64 ++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 community/alquran-widget.lua diff --git a/community/alquran-widget.lua b/community/alquran-widget.lua new file mode 100644 index 0000000..569f1b6 --- /dev/null +++ b/community/alquran-widget.lua @@ -0,0 +1,64 @@ +-- name = "AlQuran" +-- description = "AlQuran" +-- data_source = "https://quran.com/" +-- type = "widget" +-- author = "Nuhu Sule (ncalyx@gmail.com)" +-- version = "2.3" +-- foldable = "false" + +local json = require "json" +local verse_data = nil -- Store the verse translation data + +function on_alarm() + -- Fetch random verse with English translation + http:get("https://api.alquran.cloud/v1/ayah/random/en.sahih") +end + +function on_network_result(result, code) + if code >= 200 and code < 300 then + local response = json.decode(result) + + if response and response.data then + -- Store verse data including Surah name, verse number, and English translation + verse_data = { + surah = response.data.surah.englishName, + verse_number = response.data.number, + translation = response.data.text -- English translation only + } + + display_verse() + else + ui:show_message("Error loading verse data.") + end + else + -- Show error if the HTTP request fails + ui:show_message("Error fetching verse. Please try again later.") + end +end + +function display_verse() + if verse_data then + -- Prepare display lines with English translation + local display_lines = { + "Verse " .. verse_data.verse_number .. ": " .. verse_data.translation + } + local display_titles = { + "Surah: " .. verse_data.surah + } + + ui:show_lines(display_lines, display_titles) + end +end + +function on_click() + if verse_data then + -- Prepare text to copy to clipboard with English translation only + local clipboard_text = "Verse " .. verse_data.verse_number .. ": " .. verse_data.translation .. + " - Surah: " .. verse_data.surah + + system:to_clipboard(clipboard_text) + ui:show_message("Verse copied to clipboard!") + else + ui:show_message("No verse available to copy.") + end +end -- 2.43.0 From 6107bc47ce5e9fee58d14a71a6a59a3e9aec6c9f Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 15 Nov 2024 13:16:27 +0700 Subject: [PATCH 150/204] Add Timed message widget #fix --- community/timed-message-widget.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/community/timed-message-widget.lua b/community/timed-message-widget.lua index 7454e3d..12ef4db 100644 --- a/community/timed-message-widget.lua +++ b/community/timed-message-widget.lua @@ -15,11 +15,11 @@ function on_load() end if not prefs.start_time then - prefs.start_time = "09:00" + prefs.start_time = "00:00" end if not prefs.end_time then - prefs.end_time = "10:00" + prefs.end_time = "23:59" end end -- 2.43.0 From d2651f22cb56eae17fee53e414607e218a14203a Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 8 Dec 2024 09:36:10 +0800 Subject: [PATCH 151/204] Add info about new APIs --- CHANGELOG.md | 14 ++++++++++++++ README.md | 27 +++++++++++---------------- samples/calendars_enabled.lua | 3 +++ samples/icon-sample.lua | 7 +++++++ 4 files changed, 35 insertions(+), 16 deletions(-) create mode 100644 samples/calendars_enabled.lua create mode 100644 samples/icon-sample.lua diff --git a/CHANGELOG.md b/CHANGELOG.md index b3cb41e..4c962ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +### 5.3.5 + +* Added `ai` module + +### 5.3.1 + +* Added `string:trim()`, `string:starts_with()` and `string:ends_with()` methods + +### 5.3.0 + +* Added `prefs:show_dialog` method +* Added `system:show_notify()` and `system:cancel_notify()` methods +* Added support for SVG icons to the Rich UI API + ### 5.2.3 * Added `on_load()` callback diff --git a/README.md b/README.md index a074d14..5301e2b 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,12 @@ The type of script is determined by the line (meta tag) at the beginning of the # Changelog +### 5.5.4 + +* Added `icon` meta tag +* Added `private_mode` meta tag +* Added `calendar:enabled_calendar_ids()` method + ### 5.5.1 * Added `calendar:is_holiday()` method @@ -33,20 +39,6 @@ The type of script is determined by the line (meta tag) at the beginning of the * Added `aio:add_todo()` method -### 5.3.5 - -* Added `ai` module - -### 5.3.1 - -* Added `string:trim()`, `string:starts_with()` and `string:ends_with()` methods - -### 5.3.0 - -* Added `prefs:show_dialog` method -* Added `system:show_notify()` and `system:cancel_notify()` methods -* Added support for SVG icons to the Rich UI API - [Full changelog](CHANGELOG.md) # Widget scripts @@ -502,7 +494,8 @@ If there is a problem with the network, the `on_network_error_$id` callback will * `calendar:open_event(id|event_table)` - opens an event in the system calendar; * `calendar:open_new_event([start], [end])` - opens a new event in the calendar, `start` - start date of the event in seconds, `end` - end date of the event; * `calendar:add_event(event_table)` - adds event to the system calendar; -* `calendar:is_holiday(date)` - returns true if the given date is a holiday or a weekend. +* `calendar:is_holiday(date)` - returns true if the given date is a holiday or a weekend; +* `calendar:enabled_calendar_ids()` - returns list of calendar IDs enabled in the builtin Calendar widget settings. Event table format: @@ -865,10 +858,12 @@ In order for AIO Launcher to correctly display information about the script in t ``` -- name = "Covid info" +-- icon = "fontawesome_icon_name" -- description = "Cases of illness and death from covid" -- data_source = "https://covid19api.com" -- type = "widget" --- foldable = "false" +-- foldable = "true" +-- private_mode = "false" -- author = "Evgeny Zobnin (zobnin@gmail.com)" -- version = "1.0" ``` diff --git a/samples/calendars_enabled.lua b/samples/calendars_enabled.lua new file mode 100644 index 0000000..a149d6d --- /dev/null +++ b/samples/calendars_enabled.lua @@ -0,0 +1,3 @@ +function on_resume() + ui:show_text(table.concat(calendar:enabled_calendar_ids(), ", ")) +end diff --git a/samples/icon-sample.lua b/samples/icon-sample.lua new file mode 100644 index 0000000..f46e6a5 --- /dev/null +++ b/samples/icon-sample.lua @@ -0,0 +1,7 @@ +-- name = "Icon / private mode sample" +-- icon = "house" +-- private_mode = true + +function on_resume() + ui:show_text("This script have an icon and supports private mode") +end -- 2.43.0 From 0922b1f2b7835125e65414536067add2f67e81a3 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 8 Jan 2025 14:13:29 +0800 Subject: [PATCH 152/204] Add info and sample for set_edit_mode_button function --- README.md | 7 ++++++- samples/edit_menu_buttons.lua | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 samples/edit_menu_buttons.lua diff --git a/README.md b/README.md index 5301e2b..f40ec99 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,10 @@ The type of script is determined by the line (meta tag) at the beginning of the # Changelog +### 5.6.0 + +* Added `ui:set_edit_mode_buttons()` method + ### 5.5.4 * Added `icon` meta tag @@ -128,7 +132,8 @@ _AIO Launcher also offers a way to create more complex UIs: [instructions](READM * `ui:set_title()` - changes the title of the widget, should be called before the data display function (empty line - reset to the standard title); * `ui:set_folding_flag(boolean)` - sets the flag of the folded mode of the widget, the function should be called before the data display functions; * `ui:folding_flag()` - returns folding flag; -* `ui:set_progress(float)` - sets current widget progress (like in Player and Health widgets). +* `ui:set_progress(float)` - sets current widget progress (like in Player and Health widgets); +* `ui:set_edit_mode_buttons(table)` - adds icons listed in the table (formatted as `"fa:name"`) to the edit mode. When an icon is clicked, the function `on_edit_mode_button_click(index)` will be called. The `ui:show_chart()` function takes a string as its third argument to format the x and y values on the screen. For example, the string `x: date y: number` means that the X-axis values should be formatted as dates, and the Y-values should be formatted as a regular number. There are four formats in total: diff --git a/samples/edit_menu_buttons.lua b/samples/edit_menu_buttons.lua new file mode 100644 index 0000000..bf8184c --- /dev/null +++ b/samples/edit_menu_buttons.lua @@ -0,0 +1,10 @@ +edit_mode_buttons = { "fa:home", "fa:heart", "fa:gamepad" } + +function on_resume() + ui:set_edit_mode_buttons(edit_mode_buttons) + ui:show_text("Swipe to ppen edit mode") +end + +function on_edit_mode_button_click(idx) + ui:show_toast(edit_mode_buttons[idx]) +end -- 2.43.0 From c416f29b9745b46ab61b1ba25a3beac292a48fd9 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 9 Jan 2025 15:07:44 +0800 Subject: [PATCH 153/204] Fix counter widget future day bug --- community/counter-widget.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/community/counter-widget.lua b/community/counter-widget.lua index eb52909..1183ba0 100644 --- a/community/counter-widget.lua +++ b/community/counter-widget.lua @@ -47,9 +47,14 @@ function on_resume() local passed = date.diff(curr_date, start_date) local passed_days = math.floor(passed:spandays()) + if passed_days < 0 then + table.insert(gui_inst, {"text", "Error: the date can't be in the future"}) + break + end + local idx = get_milestone_idx(passed) local passed_str = passed_days.." days" - if prefs.show_milestones then + if prefs.show_milestones and passed_days > 0 then passed_str = passed_str.." / "..milestones_formatted[idx] end local next_milestone_percent = passed_days / milestones[idx+1] * 100 -- 2.43.0 From dd8e3a8379f7071b59b7ddb60c9df405352e02eb Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 10 Jan 2025 11:12:02 +0800 Subject: [PATCH 154/204] Add info about widgets:request_updates() second parameter --- README.md | 1 + README_APP_WIDGETS.md | 6 ++++-- dev/android-widget-dumper.lua | 6 +++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f40ec99..a3703d7 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ The type of script is determined by the line (meta tag) at the beginning of the ### 5.6.0 * Added `ui:set_edit_mode_buttons()` method +* Added size argument to `widgets:request_updates()` method ### 5.5.4 diff --git a/README_APP_WIDGETS.md b/README_APP_WIDGETS.md index f270968..ee113cb 100644 --- a/README_APP_WIDGETS.md +++ b/README_APP_WIDGETS.md @@ -2,7 +2,9 @@ Starting from version 5.2.0, AIO Launcher supports interaction with app widgets ### Introduction -Before you start working with app widgets, you need to find out the app widget provider's name and the widget interface structure. Both can be done using the [android-widget-dumper.lua](samples/android-widget-dumper.lua) script. Enter the package name of the desired application in its global variable `app_pkg` and run the script. It will display all the widgets available for that application. Click on the widget name, and you will see its provider name (first line) and a tree-like structure of its UI. Click on the text to copy it. +Before you start working with app widgets, you need to find out the app widget provider's name and the widget interface structure. Both can be done using the [android-widget-dumper.lua](dev/android-widget-dumper.lua) script. Enter the package name of the desired application in its global variable `app_pkg` and run the script. It will display all the widgets available for that application. Click on the widget name, and you will see its provider name (first line) and a tree-like structure of its UI. Click on the text to copy it. + +_Note: Some widgets can dynamically change their UI depending on their size. If you encounter such a widget, update the value of the `widget_size` variable by specifying a string from `1x1` to `4x4`. In other cases, leave the value as `nil`._ Take, for example, The Weather Channel app (package name: `com.weather.Weather`). Install this app and add its package name to the dumper script. After running the dumper, it will show you a list of widgets. Click on "Widget 2x2". A widget configuration screen will open. Click Done at the top of the configurator screen, and you will see the data of this widget. The first line will be the provider's name: @@ -43,7 +45,7 @@ end Using the `widgets:setup()` method, we ask the launcher to prepare a widget for us. The method returns an identifier needed to work with the widget, or `nil` if an error occurred. Note that this function may trigger the widget's configuration window if it has one. -Having obtained the identifier, we can use it to communicate with the widget. For this purpose, we call the `widgets:request_updates()` method: +Having obtained the identifier, we can use it to communicate with the widget. For this purpose, we call the `widgets:request_updates()` method (you can specify the widget size as a string from 1x1 to 4x4 as the second argument): ``` widgets:request_updates(prefs.wid) diff --git a/dev/android-widget-dumper.lua b/dev/android-widget-dumper.lua index b0b89e1..25c030c 100644 --- a/dev/android-widget-dumper.lua +++ b/dev/android-widget-dumper.lua @@ -6,6 +6,10 @@ app_pkg = "com.weather.Weather" --app_pkg = "com.android.chrome" --app_pkg = "com.whatsapp" +-- Widget size (string from "1x1" to "4x4") +-- In most cases you can use nil +widget_size = nil + -- Globals labels = {} providers = {} @@ -35,7 +39,7 @@ end function on_click(idx) if w_content == "" then wid = widgets:setup(providers[idx]) - widgets:request_updates(wid) + widgets:request_updates(wid, widget_size) else system:copy_to_clipboard(w_content) end -- 2.43.0 From da7adad7494e713de8e3657a1a326b2765d0ef17 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 12 Jan 2025 09:04:16 +0800 Subject: [PATCH 155/204] Update rich ui docs --- README_RICH_UI.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README_RICH_UI.md b/README_RICH_UI.md index 52dbae1..00b267a 100644 --- a/README_RICH_UI.md +++ b/README_RICH_UI.md @@ -50,7 +50,7 @@ Here we used the `gravity` parameter to change the location of the element in th Also, there are two limitations to know about: -1. The `center_h` value is applied to each element separately, meaning if you add two lines with the gravity value `center_h` in one line, they will not both be grouped and displayed in the center, but instead, they will split the screen in half and be displayed each in the center of its half. This situation can be rectified by using the `value anchor_prev` as the value for gravity. This flag anchors the current element to the previous element of the current line, so that the `gravity` value of the previous element starts affecting both elements. +1. The `center_h` value is applied to each element separately, meaning if you add two lines with the gravity value `center_h` in one line, they will not both be grouped and displayed in the center, but instead, they will split the screen in half and be displayed each in the center of its half. This situation can be rectified by using the `anchor_prev` as the value for gravity. This flag anchors the current element to the previous element of the current line, so that the `gravity` value of the previous element starts affecting both elements. 2. The `right` value affects not only the element to which it is applied but also all subsequent elements in the current line. That means if you add another button after "Button #2", it will also be on the right side after "Button #2". Surely you will want to add icons to your UI. There are several ways to do this. The first way is to embed the icon directly into the text, in this case, you can use any icon from the FontAwesome set: @@ -85,8 +85,8 @@ Handling clicks on elements works the same as when using the `ui` module API. Ju This is all you need to know about the new API. Below is an example demonstrating all supported elements and all their default parameters: ``` -{"text", "", {size = 17, color = "", gravity = "left", expand = false}}, -{"button", "", {color = "", gravity = "left"}}, +{"text", "", {size = 17, color = "", gravity = "left"}}, +{"button", "", {color = "", gravity = "left", expand = "false"}}, {"icon", "", {size = 17, color = "", gravity = "left"}}, {"progress" "", {progress = 0, color = "", gravity = "left"}}, {"new_line", 0}, -- 2.43.0 From 3b033d6086cb3f5af965134903769ea731c49c42 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 12 Jan 2025 09:06:43 +0800 Subject: [PATCH 156/204] Update what to do script to new API endpoint --- community/what-to-do-widget.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/community/what-to-do-widget.lua b/community/what-to-do-widget.lua index ad8d41a..2c852ee 100644 --- a/community/what-to-do-widget.lua +++ b/community/what-to-do-widget.lua @@ -1,6 +1,6 @@ -- name = "What to do?" -- description = "Let's find you something to do" --- data_source = "https://www.boredapi.com/" +-- data_source = "https://bored.api.lewagon.com/" -- type = "widget" -- author = "Evgeny Zobnin (zobnin@gmail.com)" -- version = "1.0" @@ -12,7 +12,7 @@ end function on_click() system:vibrate(100) - http:get("http://www.boredapi.com/api/activity/") + http:get("https://bored.api.lewagon.com/api/activity/") end function on_network_result(result) -- 2.43.0 From 79fe5e8e7b74d85f27099e1681d94df36f925d56 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 12 Jan 2025 11:13:17 +0800 Subject: [PATCH 157/204] Update rich gui sample --- samples/rich-gui-sample.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/samples/rich-gui-sample.lua b/samples/rich-gui-sample.lua index 6776379..6c1e520 100644 --- a/samples/rich-gui-sample.lua +++ b/samples/rich-gui-sample.lua @@ -35,6 +35,12 @@ function on_resume() {"spacer", 2}, {"button", "fa:check"}, {"new_line", 2}, + {"button", "Button #1", {expand = true}}, + {"spacer", 2}, + {"button", "Button #2", {expand = true}}, + {"spacer", 2}, + {"button", "fa:check"}, + {"new_line", 2}, {"icon", "fa:microphone", {size = 17, color = "#00ff00", gravity = "center_v"}}, {"spacer", 4}, {"icon", "fa:microphone", {size = 22, gravity = "center_v"}}, -- 2.43.0 From fa1dc0ad313f5f45bebd2802701045f0bf0489a4 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 13 Jan 2025 19:14:35 +0800 Subject: [PATCH 158/204] Move meta widget to samples --- {community => samples}/meta-widget.lua | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {community => samples}/meta-widget.lua (100%) diff --git a/community/meta-widget.lua b/samples/meta-widget.lua similarity index 100% rename from community/meta-widget.lua rename to samples/meta-widget.lua -- 2.43.0 From d1e6efa1d40a7822355a89eef56f7451e686889a Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 19 Jan 2025 21:04:14 +0800 Subject: [PATCH 159/204] Add ui:set_expandable() function --- README.md | 6 ++++++ samples/expandable-sample.lua | 9 +++++++++ 2 files changed, 15 insertions(+) create mode 100644 samples/expandable-sample.lua diff --git a/README.md b/README.md index a3703d7..d438e5e 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,10 @@ The type of script is determined by the line (meta tag) at the beginning of the # Changelog +### 5.6.1 + +* Added `ui:set_expandable()` and `ui:is_expanded()` methods + ### 5.6.0 * Added `ui:set_edit_mode_buttons()` method @@ -133,6 +137,8 @@ _AIO Launcher also offers a way to create more complex UIs: [instructions](READM * `ui:set_title()` - changes the title of the widget, should be called before the data display function (empty line - reset to the standard title); * `ui:set_folding_flag(boolean)` - sets the flag of the folded mode of the widget, the function should be called before the data display functions; * `ui:folding_flag()` - returns folding flag; +* `ui:set_expandable()` - shows expand button on widget update; +* `ui:is_expanded()` - checks if expanded mode is enabled; * `ui:set_progress(float)` - sets current widget progress (like in Player and Health widgets); * `ui:set_edit_mode_buttons(table)` - adds icons listed in the table (formatted as `"fa:name"`) to the edit mode. When an icon is clicked, the function `on_edit_mode_button_click(index)` will be called. diff --git a/samples/expandable-sample.lua b/samples/expandable-sample.lua new file mode 100644 index 0000000..0d63ab3 --- /dev/null +++ b/samples/expandable-sample.lua @@ -0,0 +1,9 @@ +function on_resume() + ui:set_expandable(true) + + if ui:is_expanded() then + ui:show_text("Expanded mode") + else + ui:show_text("Standard mode") + end +end -- 2.43.0 From b5b701ce1c7e95390544eb9083a65cd843832385 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 20 Jan 2025 18:32:31 +0800 Subject: [PATCH 160/204] birthday widget: add expanded mode support --- community/birthdays-widget.lua | 43 ++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/community/birthdays-widget.lua b/community/birthdays-widget.lua index 2f5ed08..f3d0afe 100644 --- a/community/birthdays-widget.lua +++ b/community/birthdays-widget.lua @@ -3,7 +3,7 @@ -- description = "Shows upcoming birthdays from the contacts" -- type = "widget" -- author = "Andrey Gavrilov" --- version = "1.1" +-- version = "1.2" local prefs = require "prefs" local fmt = require "fmt" @@ -43,23 +43,40 @@ function redraw() table.sort(contacts,function(a,b) return a.begin < b.begin end) events = {} local lines = {} + local lines_exp = {} + prev_begin = contacts[1].begin for i,v in ipairs(contacts) do - local fmt_out = fmt_line(v) - local insert = 0 - if #lines == 0 then - insert = 1 - elseif not (fmt_out == lines[#lines]) then - insert = 1 - end - if insert == 1 then + local fmt_out = fmt_line(v) + local insert = 0 + if #lines == 0 then + insert = 1 + elseif not (fmt_out == lines[#lines]) then + insert = 1 + end + if insert == 1 then + if #lines_exp >= prefs.count and prev_begin ~= v.begin then + break + end table.insert(events, v) - table.insert(lines, fmt_out) - if #lines == prefs.count then - break + if #lines < prefs.count then + table.insert(lines, fmt_out) end + table.insert(lines_exp, fmt_out) + prev_begin = v.begin end end - ui:show_lines(lines) + if ui.set_expandable then + if #lines_exp == #lines then + ui:set_expandable(false) + else + ui:set_expandable(true) + end + end + if ui.is_expanded and ui:is_expanded() then + ui:show_lines(lines_exp) + else + ui:show_lines(lines) + end end function fmt_line(event) -- 2.43.0 From adfa6fad130a44ce445353ce2644f80b261bb7dd Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 20 Feb 2025 07:53:57 +0800 Subject: [PATCH 161/204] Add step-by-step tutorial --- README.md | 1 + README_INTRO.md | 201 +++++++++++++++++++++++++++++ samples/cat_facts.lua | 23 ++++ samples/custom-drawer-menu.lua | 20 +++ samples/interactive_counter.lua | 25 ++++ samples/remove_sale_card.lua | 4 + samples/search-engine-selector.lua | 25 ++++ 7 files changed, 299 insertions(+) create mode 100644 README_INTRO.md create mode 100644 samples/cat_facts.lua create mode 100644 samples/custom-drawer-menu.lua create mode 100644 samples/interactive_counter.lua create mode 100644 samples/remove_sale_card.lua create mode 100644 samples/search-engine-selector.lua diff --git a/README.md b/README.md index d438e5e..36c45ed 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ The type of script is determined by the line (meta tag) at the beginning of the # Links +* [Step-by-step guide to writing scripts for AIO Launcher](README_INTRO.md) * [AIO Scripting Telegram Group](https://t.me/aio_scripting) * [AIO Script Store app](https://play.google.com/store/apps/details?id=ru.execbit.aiostore) * [Lua Guide](https://www.lua.org/pil/contents.html) diff --git a/README_INTRO.md b/README_INTRO.md new file mode 100644 index 0000000..2eda25a --- /dev/null +++ b/README_INTRO.md @@ -0,0 +1,201 @@ +# Creating Your Own Scripts for AIO Launcher: A Step-by-Step Guide for Beginners + +**AIO Launcher** isn’t just an alternative to the standard Android home screen — it transforms your device into a powerful tool for personalization through Lua scripting. In this article, we’ll show you how to write your first scripts, presenting three examples ranging from simple text output to an interactive widget and integration with an open API. We’ll also explain how to add your scripts to the launcher via AIO Store. + +--- + +## How to Create and Load Scripts + +You can write scripts for AIO Launcher in any text editor—whether it’s Sublime Text, Visual Studio Code, or even Notepad. The key is to save your file with the **.lua** extension. Then, using the **AIO Store** app, you can easily add your file to the launcher. In AIO Store, at the end of the list of installed scripts there’s a special "Add Script" button that lets you add your own script. + +--- + +## Example 1. Hello, World! + +The simplest script is the classic "Hello, World!" In this example, when the widget is launched, a welcome message appears on the screen. + +```lua +-- name = "Hello, World!" +-- type = "widget" + +function on_load() + -- On the first load of the widget, display the text "Hello, World!". + ui:show_text("Hello, World!") +end +``` + +*Explanation:* + +- The metadata at the beginning of the file sets the script’s name and type. +- The `on_load()` function is called when the script starts. +- The `ui:show_text()` method displays the text on the widget. + +--- + +## Example 2. Interactive Counter + +In the second example, we create an interactive counter using two buttons. Instead of displaying the count separately, the current counter value is embedded directly in the label of the "Increase" button. When you press "Increase", the counter increments and the button label updates; pressing "Reset" sets the counter back to zero. + +```lua +-- name = "Interactive Counter" +-- type = "widget" + +-- Global variable to store the current count. +local counter = 0 + +-- Function to update the display: shows two buttons with the counter embedded in the first button. +function update_display() + ui:show_buttons({ "Increase (" .. counter .. ")", "Reset" }) +end + +function on_load() + update_display() +end + +-- Function to handle button clicks. +function on_click(index) + if index == 1 then + counter = counter + 1 + elseif index == 2 then + counter = 0 + end + update_display() +end +``` + +*Explanation:* + +- When the script launches, the `on_load()` function calls `update_display()`, which displays two buttons. +- The first button’s label includes the current counter value (e.g., "Increase (0)"). +- The `on_click(index)` function handles button presses: if the first button is pressed, the counter increases; if the second button is pressed, it resets to zero. +- After each action, `update_display()` updates the button labels accordingly. + +--- + +## Example 3. Cat Facts + +In the third example, we use the Cat Facts API to retrieve a random cat fact. This version uses the `on_alarm` callback instead of `on_load` so that the widget automatically updates every 30 minutes. + +```lua +-- name = "Cat Facts" +-- type = "widget" + +-- on_alarm is called automatically, up to once every 30 minutes, to refresh the widget. +function on_alarm() + ui:show_text("Loading a random cat fact...") + http:get("https://catfact.ninja/fact") +end + +function on_network_result(body, code) + if code == 200 then + local json = require "json" + local data = json.decode(body) -- The json module converts the JSON string into a Lua table. + if data and data.fact then + ui:show_text("Random Cat Fact:\n" .. data.fact) + else + ui:show_text("Failed to retrieve a cat fact.") + end + else + ui:show_text("Error loading data. Code: " .. code) + end +end +``` + +*Explanation:* + +- In this example, the `on_alarm()` function is used to trigger an automatic update every 30 minutes, ensuring that your widget stays fresh with a new cat fact. +- The `http:get()` call fetches data from the Cat Fact API, and the `json` module decodes the returned JSON string into a Lua table for easy access. + +Remember: there’s also an `on_resume` callback that is invoked every time you return to the home screen, which you can use for additional actions if desired. + +--- + +## Example 4. Search Engine Selector for the Search Window + +In this example, we demonstrate how to create a search script for the AIO Launcher search window. Unlike widget scripts, search scripts are activated when the search window is opened and as the user types their query. This script presents two search suggestions — one for searching on Google and another for Bing. When a suggestion is clicked, the corresponding search engine opens in the browser. + +```lua +-- name = "Search Engine Selector" +-- type = "search" + +local lastQuery = "" + +function on_search(query) + lastQuery = query + local results = {} + if #query > 0 then + table.insert(results, "Search Google for: " .. query) + table.insert(results, "Search Bing for: " .. query) + end + search:show_lines(results) +end + +function on_click(index) + if index == 1 then + system:open_browser("https://www.google.com/search?q=" .. lastQuery) + return true + elseif index == 2 then + system:open_browser("https://www.bing.com/search?q=" .. lastQuery) + return true + end + return false +end +``` + +*Explanation:* + +- This search script is identified as a search script by the meta tag `-- type = "search"`. +- The global variable `lastQuery` stores the most recent search query. +- The `on_load()` function is called each time the search window is opened, displaying a default message. +- The `on_search(query)` function is invoked whenever the user types something; it saves the query and builds a list of suggestions, which are displayed via `search:show_lines()`. +- The `on_click(index)` function handles the user's selection: if the first result is clicked, the system opens Google with the query; if the second is clicked, Bing is used. + +--- + +## Example 5. Side Menu Script + +This example demonstrates how to create a side menu (drawer) script for AIO Launcher. Side menu scripts allow you to add custom items to the launcher's side menu. The script type is defined by the meta tag `-- type = "drawer"`, and the primary callback function is `on_drawer_open()`, which is invoked when the side menu is opened. When the user selects an item, the `on_click(index)` function is called to execute the corresponding action. + +```lua +-- name = "Custom Drawer Menu" +-- type = "drawer" + +function on_drawer_open() + local menuItems = {"Open Website", "Update list", "Launch App"} + drawer:show_list(menuItems) +end + +function on_click(index) + if index == 1 then + system:open_browser("https://www.example.com") + elseif index == 2 then + local menuItems = {"Open Website", "List updated", "Launch App"} + drawer:show_list(menuItems) + elseif index == 3 then + apps:launch("com.android.contacts") + end + return true +end +``` + +*Explanation:* + +- The meta tags at the top specify the script’s name and indicate that it is a drawer (side menu) script. +- The `on_drawer_open()` function is automatically called when the side menu is opened; it builds a list of menu items (in this case, three items) and displays them using `drawer:show_list()`. +- The `on_click(index)` function handles user selection: clicking the first item opens a website, the second updates items list, and the third launches an application. + +## Conclusion + +Creating scripts for AIO Launcher opens up endless possibilities for customizing and extending the functionality of your Android device. From simple text output to interactive widgets and integration with external services, all of this is accessible thanks to the powerful API of AIO Launcher and the flexibility of Lua. Use any text editor you prefer to write your scripts, then easily add them to the launcher via AIO Store using the dedicated "Add Script" button at the end of your installed scripts list. Experiment, integrate new data sources, and create unique solutions that make your home screen truly your own! + +--- + +## Sources for Further Study + +- citeturn0search0 [Official AIO Launcher Scripts Repository](https://github.com/zobnin/aiolauncher_scripts) +- [AIO Launcher on Google Play](https://play.google.com/store/apps/details?id=ru.execbit.aiolauncher&hl=en) +- [Lua Documentation](https://www.lua.org/pil/) +- [Cat Fact API](https://catfact.ninja/fact) +- [AIO Store](https://play.google.com/store/apps/details?id=ru.execbit.aiolauncher.store) + +These resources will help you dive deeper into creating scripts for AIO Launcher and explore new ways to extend your Android device’s functionality. diff --git a/samples/cat_facts.lua b/samples/cat_facts.lua new file mode 100644 index 0000000..494fd70 --- /dev/null +++ b/samples/cat_facts.lua @@ -0,0 +1,23 @@ +-- name = "Cat Facts" +-- type = "widget" + +-- on_alarm is called automatically, up to once every 30 minutes, to refresh the widget. +function on_alarm() + ui:show_text("Loading a random cat fact...") + http:get("https://catfact.ninja/fact") +end + +function on_network_result(body, code) + if code == 200 then + local json = require "json" + local data = json.decode(body) -- The json module converts the JSON string into a Lua table. + if data and data.fact then + ui:show_text("Random Cat Fact:\n" .. data.fact) + else + ui:show_text("Failed to retrieve a cat fact.") + end + else + ui:show_text("Error loading data. Code: " .. code) + end +end + diff --git a/samples/custom-drawer-menu.lua b/samples/custom-drawer-menu.lua new file mode 100644 index 0000000..dab0aab --- /dev/null +++ b/samples/custom-drawer-menu.lua @@ -0,0 +1,20 @@ +-- name = "Custom Drawer Menu" +-- type = "drawer" + +function on_drawer_open() + local menuItems = {"Open Website", "Update list", "Launch App"} + drawer:show_list(menuItems) +end + +function on_click(index) + if index == 1 then + system:open_browser("https://www.example.com") + elseif index == 2 then + local menuItems = {"Open Website", "List updated", "Launch App"} + drawer:show_list(menuItems) + elseif index == 3 then + apps:launch("com.android.contacts") + end + return true +end + diff --git a/samples/interactive_counter.lua b/samples/interactive_counter.lua new file mode 100644 index 0000000..e358ed6 --- /dev/null +++ b/samples/interactive_counter.lua @@ -0,0 +1,25 @@ +-- name = "Interactive Counter" +-- type = "widget" + +-- Global variable to store the current count. +local counter = 0 + +-- Function to update the display: shows two buttons with the counter embedded in the first button. +function update_display() + ui:show_buttons({ "Increase (" .. counter .. ")", "Reset" }) +end + +function on_load() + update_display() +end + +-- Function to handle button clicks. +function on_click(index) + if index == 1 then + counter = counter + 1 + elseif index == 2 then + counter = 0 + end + update_display() +end + diff --git a/samples/remove_sale_card.lua b/samples/remove_sale_card.lua new file mode 100644 index 0000000..7253928 --- /dev/null +++ b/samples/remove_sale_card.lua @@ -0,0 +1,4 @@ +function on_load() + aio:remove_widget("sale") + ui:show_text("Sale widget not removed :)") +end diff --git a/samples/search-engine-selector.lua b/samples/search-engine-selector.lua new file mode 100644 index 0000000..1749bee --- /dev/null +++ b/samples/search-engine-selector.lua @@ -0,0 +1,25 @@ +-- name = "Search Engine Selector" +-- type = "search" + +local lastQuery = "" + +function on_search(query) + lastQuery = query + local results = {} + if #query > 0 then + table.insert(results, "Search Google for: " .. query) + table.insert(results, "Search Bing for: " .. query) + end + search:show_lines(results) +end + +function on_click(index) + if index == 1 then + system:open_browser("https://www.google.com/search?q=" .. lastQuery) + return true + elseif index == 2 then + system:open_browser("https://www.bing.com/search?q=" .. lastQuery) + return true + end + return false +end -- 2.43.0 From 605d4636d81fb1683fed4491f9bd9892278c6b1d Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 26 Mar 2025 08:38:26 +0800 Subject: [PATCH 162/204] Add App Categries embed to docs --- README.md | 1 + samples/build_ui_sample.lua | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 36c45ed..e5fef18 100644 --- a/README.md +++ b/README.md @@ -302,6 +302,7 @@ The function takes a command table of this format as a parameter: `appbox [NUM]` - my apps (number of lines); `applist [NUM]` - apps list (number of lines); `appfolders [NUM]` - app folders; +`appcategories [NUM]` - app categries; `timer` - timers; `mailbox [NUM]` - mail widget; `dialer` - dialer; diff --git a/samples/build_ui_sample.lua b/samples/build_ui_sample.lua index 49fd0c1..e73d203 100644 --- a/samples/build_ui_sample.lua +++ b/samples/build_ui_sample.lua @@ -15,5 +15,11 @@ function on_resume() "space 2", "text Timezones", "worldclock new_york kiev bangkok", + "space 2", + "text Categories", + "appcategories 3", + "space 2", + "text Apps", + "apps 2", } end -- 2.43.0 From f2e28096c57dd05ccd6dcb586aeda488c61aef5b Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 1 Apr 2025 20:11:10 +0800 Subject: [PATCH 163/204] Update shell-widget.lua --- main/shell-widget.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/shell-widget.lua b/main/shell-widget.lua index 8049d41..0d10ae1 100644 --- a/main/shell-widget.lua +++ b/main/shell-widget.lua @@ -16,7 +16,7 @@ function on_resume() end function redraw() - ui:show_text(current_output) + ui:show_text("%%txt%%"..current_output) end function on_click(idx) -- 2.43.0 From e94808c35ac193c8d336d768a23d87d15c70d1e0 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 1 Apr 2025 20:11:36 +0800 Subject: [PATCH 164/204] Update scripts.zip --- scripts.md5 | 2 +- scripts.zip | Bin 18537 -> 18546 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts.md5 b/scripts.md5 index a8bec8d..92b67ce 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -b8a11f997ee3311bc357719223dd89b9 +22f85f22af09e28b03d79c1084be3ef1 diff --git a/scripts.zip b/scripts.zip index 850779ec9407ac41ca9f308848562bd04b8999bd..7033d7a2084b190662b42f00b9b40aeed8e53208 100644 GIT binary patch delta 1041 zcmaDkf$`G>MxFp~W)=|!1_lm>30V_)beV-GJlkk9laVoO@-;?v5N{Kc11A$h_hct- zZ4h^J0e1is!d3C_t54;&nj46{N1+>82Hi0BY#ubxa3PKc%3&k-4Wy^#uz_J^K zGZ-23CrgRygSkGUJdE{=duyXs-5Nor!@#fI)_#I3qPDN4GpPB|Wu7FQ+sy zG=!6ZS@GcW^rP2brX5+mpV`DsC;zQ{Jnau<1qB^PWh(XtLmf_j2`X z)28j%Tk$}+$yuJK`7LAmltxot1>MSQgL{uPJbtb@a9z{;erMMK_18i_%H$@j`;geb zg!9$T=z~T;|ZD#^Iqiw`G^}Yn@Elb}cLJ^@2-xG*8Zwv zh4c5^zu>#dKYn@ivy$m6t3CKFj?_-coHFHM$u@3f?$e9UsPuIIojo^2JSr>I`aW+y zA_c4{nS4{+1ROO262Z*Ch)a>y19PWJ7cw#yO=g$X1apmL>p-%b6u{|a^CJaME+AJ& z8xpN?+IyH78zxKZ8G{uE>IpM4mQ7C8Hw1HM>bvtWW>0=-4dIH~@G=2qmF*zhaJxp3 z;+ysmqqrTmGBRdOKIj+@OpuaJfuMw#;}i-^e}|mHfL2O6hX7Mso^vRWeZ)Bln6}hi zB6v}f)Z`u)Ef!GPnH=aWt+=8@C-PZqNwEbm`ApZ!Qi4%5(ygr7()Z#L2;~*1!Pica>pck)6EO)fA-u&AR!Q^tc!p ztmPOOgizG4pX6o*bfUGJ46~*-!(>}+@yUg5$_fpE;j=G%KJWu*`BI=g5-55k^cW`V z=t)mL@1`tQb}EEv_QSh6JPZtf^cfh$P!uLj7I3!%2C2Wh4CB4YIY4&VtcwTCYu3@vvvx;|K}@01QlXn*aa+ delta 936 zcmew~f$`-8MxFp~W)=|!1_lm>2}u)qbeVUi8g8_i$;jw8`5L1-Gh?CQCME|?rX5|A zow&6@lA8;-1DF`MPCm%11Ll6<&0u1TnH(vg1?IL1Br!5BnEX-@qF7ugju9wZCTszg z-6)*F$e2D^N>m@r^%3P^tlvFNC)}W}+s%}bf#D1j1A_pA3`227YEF)Bd1gv_YKdM> zX<}#yCj)a(AVVt90qLa`+zgB?FPIq^z{J#`-Fb%%c<%faZBb7zxVVmyNkrol>)l-v zT`txxsi!8au=(|M>XR)U4@*{vIUavJ(S22J$&T4J^El4epIz2eqLl0W=>})qlAr7E`nKjwdu5q_WcCjC$D!-C zEcttAHQTglawlHD*`Qb)skT`0C6DIowq^J9&)5sh?3}CRFq!*&)NV`+?G41s#e^G#XAcJ!-|~A zkHk&DF(N4u%nXdLTxmTpcb;@1BV*QN0a;Bj*G9GuB)eMyoJ=;qR`BEka!s`%v6-&D zhl#ObvWlKDSaFn|Fe78$k{7=VeCVM(LH?$uROy-tFc9 zbo(DS8RkfRhROB%l9S)KD=}?Lo*dyW!+h16Ve)Tl$;lJkmF4nIh5Ss2{FMeYqy=cM b7>b$VlP|j40nHKc0J&4w!=7!kBgjSoMx Date: Wed, 16 Apr 2025 07:39:50 +0800 Subject: [PATCH 165/204] Calendar menu: fix first load --- main/calendar-menu.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main/calendar-menu.lua b/main/calendar-menu.lua index 7cbe4ae..34c67a5 100644 --- a/main/calendar-menu.lua +++ b/main/calendar-menu.lua @@ -15,7 +15,6 @@ local calendars = {} function on_drawer_open() events = calendar:events() calendars = calendar:calendars() - add_cal_colors(events, calendars) if events == "permission_error" then calendar:request_permission() @@ -24,6 +23,8 @@ function on_drawer_open() have_permission = true + add_cal_colors(events, calendars) + if #events == #drawer:items() then return end -- 2.43.0 From cc4813730a92936f6cd5df7a6723c4c291f2abef Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 16 Apr 2025 07:40:07 +0800 Subject: [PATCH 166/204] Update scripts.zip --- scripts.md5 | 2 +- scripts.zip | Bin 18546 -> 18545 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts.md5 b/scripts.md5 index 92b67ce..8b1a7b7 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -22f85f22af09e28b03d79c1084be3ef1 +b0140e81bebb47aa36f22dcbeb809a3e diff --git a/scripts.zip b/scripts.zip index 7033d7a2084b190662b42f00b9b40aeed8e53208..8291911b198f84577dd921e24dd0603df1ecee1c 100644 GIT binary patch delta 988 zcmew~f$`%6#tD|pf8YGuXmgMeL~mlU=j453Ga*WD$(J7{ObiSkC;M>A)@#4}mkz?E z72FJrEH9WD7{J8Z5Z~_G1_FD3hjZw2o2fLlwr*;)ohtWz%l2tXBH43zvc2Ox&*eq^ zy1!cgblIePubh?6&o=-3%=unk=M&or=|Oc*Wjzj>zI5zM-Pp_F{P3V!<3YUxCQ|I( zUR7_tuCU{26!ysWSRLwLf97Vyi<4a`=bb&2P5w7zJX&#sbBkx8+)MFaUqmKel$-kP zSpIV66UIN+eG^JOAlAeFD?rS3d5qGfZ`Wp;?CD?8IOUzGvwIzrS;M=FDru*!nK^wA z%|H3x{-n`MzhjGJQ-!-iC%OLg;Z<0@OX1zgKb_mUr?Kcar}pQR_#NcFEpxp7s%duW zf~}WSH@Z(aSSVTad^Kyb_|~OM{#{IPm-Reny=>>ZmaEDxJ=_OlQm(D=vrG&;mv+rw zd++R}_m0-Rxp4Nj=;mvc-j3};HQH5nA;Iz5TQeI)R%@8QA?}yX1dEX zzI)iP>7GF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 zCgGD0@v5=+2yv$Zli23>ypx$gDRFbFKp!|sZWa@o4qDdr9*0O6LBCixGxxi9s+8-b$N9wsk)GXAmaFt;JJNt~26!TVIhRGLsMc7#xm_a_6tmrB|S>9QW(RZ?)a|q+z z$&;N!8M7w8bWURAo9yEf$>=wEnM)|+waI^6;usSrN4rKavP|CM8qBzUGKX6@qvqrU zw@5~b$-CTQnUnMxCfDgpPJZpKH2Jx;5U&I Date: Wed, 23 Apr 2025 19:32:49 +0800 Subject: [PATCH 167/204] Update notify module docs --- README.md | 19 +++++++++++++----- samples/notify_sample.lua | 41 +++++++++++++-------------------------- 2 files changed, 27 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index e5fef18..824be97 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,10 @@ The type of script is determined by the line (meta tag) at the beginning of the # Changelog +### 5.7.0 + +* Many changes in the `notify` module + ### 5.6.1 * Added `ui:set_expandable()` and `ui:is_expanded()` methods @@ -125,6 +129,7 @@ The list output functions support HTML and Markdown (see User Interface section ## User Interface _Available only in widget scripts._ + _AIO Launcher also offers a way to create more complex UIs: [instructions](README_RICH_UI.md)_ * `ui:show_text(string)` - displays plain text in widget, repeated call will erase previous text; @@ -649,6 +654,7 @@ _Avaialble from: 5.3.6._ ## AI _Avaialble from: 5.3.5._ + _Requires subscription._ * `ai:complete(text)` - send message to the AI; @@ -671,17 +677,19 @@ _Keep in mind that the launcher imposes certain limitations on the use of this m ## Reading notifications _Available only in widget scripts._ + _Avaialble from: 4.1.3._ _This module is intended for reading notifications from other applications. To send notifications, use the `system` module._ -* `notify:request_current()` - requests current notifications from the launcher; +* `notify:list()` - returns list of current notifications as table of tables; * `notify:open(key)` - opens notification with specified key; * `notify:close(key)` - removes the notification with the specified key; -* `notify:do_action(key, action_id)` - sends notification action (_available from: 4.1.5_); -* `notify:consumed(key)` - mark notification as consumed so built-in Notifications widget will not show it; +* `notify:do_action(key, action_id)` - sends notification action (_available from: 4.1.5_). -The `notify:request_current()` function asks for all current notifications. The Launcher returns them one by one to the `on_notify_posted(table)` callback, where table is the table representing the notification. The same callback will be called when a new notification appears. When the notification is closed, the `on_notify_removed(table)` colbeck will be called. +The launcher triggers callback when a notification is received or removed: + +* `on_notifications_updated()` – notification list changed; Notification table format: @@ -702,7 +710,7 @@ Notification table format: `actions` - table notifications actions with fields: `id`, `title`, `have_input` (_available from: 4.1.5_); ``` -Keep in mind that the AIO Launcher also calls `request_current()` every time you return to the launcher, which means that all scripts will also get notification information in the `on_notify_posted()` callback every time you return to the desktop. +Keep in mind that the AIO Launcher also request current notifications every time you return to the launcher, which means that all scripts will also get the `on_notifications_updated() callback called`. ## Files @@ -770,6 +778,7 @@ prefs._dialog_order = "message,start_time,end_time" ## Animation and real time updates _Available only in widget scripts._ + _Avaialble from: 4.5.2_ The scripts API is designed in a way that every function that changes a widget's UI updates the entire interface. This approach makes the API as simple and convenient as possible for quick scripting, but it also prevents the creation of more complex scripts that change the UI state very often. diff --git a/samples/notify_sample.lua b/samples/notify_sample.lua index eb3c755..e79747f 100644 --- a/samples/notify_sample.lua +++ b/samples/notify_sample.lua @@ -1,34 +1,19 @@ +-- This is an example of a widget that, +-- when a notification is added or removed, +-- simply reads the current notifications and refreshes the screen. -local curr_notab = {} -local curr_titletab = {} -local curr_keystab = {} - -function on_notify_posted(n) - curr_notab[n.key] = n - redraw() +function on_resume() + refresh() end -function on_notify_removed(n) - curr_notab[n.key] = nil - redraw() - ui:show_toast("Notify from "..n.package.." removed") +function on_notifications_updated() + refresh() end -function redraw() - fill_tabs(curr_notab) - ui:show_lines(curr_titletab) -end - -function on_click(i) - notify:open(curr_keystab[i]) -end - -function fill_tabs(tab) - curr_titletab = {} - curr_keystab = {} - - for k,v in pairs(tab) do - table.insert(curr_titletab, v.title) - table.insert(curr_keystab, v.key) - end +function refresh() + local titles = map( + function(it) return it.title end, + notify:list() + ) + ui:show_lines(titles) end -- 2.43.0 From 4904a0050afc9c2958e849a1086d76f15b9e35b9 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 29 Apr 2025 06:59:41 +0800 Subject: [PATCH 168/204] Add ui:show_image() --- README.md | 4 +++- samples/image_sample.lua | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 samples/image_sample.lua diff --git a/README.md b/README.md index 824be97..9fb3bcd 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ The type of script is determined by the line (meta tag) at the beginning of the ### 5.7.0 +* Added `ui:show_image(uri)` method * Many changes in the `notify` module ### 5.6.1 @@ -138,6 +139,7 @@ _AIO Launcher also offers a way to create more complex UIs: [instructions](READM * `ui:show_buttons(names, [colors])` - displays a list of buttons, the first argument is a table of strings, the second is an optional argument, a table of colors in the format #XXXXXX; * `ui:show_progress_bar(text, current_value, max_value, [color])` - shows the progress bar; * `ui:show_chart(points, [format], [title], [show_grid], [folded_string], [copyright])` - shows the chart, points - table of coordinate tables, format - data format (see below), title - chart name, show\_grid - grid display flag, folded\_string - string for the folded state (otherwise the name will be shown), copyright - string displayed in the lower right corner; +* `ui:show_image(uri)` - show image by URL; * `ui:show_toast(string)` - shows informational message in Android style; * `ui:default_title()` - returns the standard widget title (set in the `name` metadata); * `ui:set_title()` - changes the title of the widget, should be called before the data display function (empty line - reset to the standard title); @@ -710,7 +712,7 @@ Notification table format: `actions` - table notifications actions with fields: `id`, `title`, `have_input` (_available from: 4.1.5_); ``` -Keep in mind that the AIO Launcher also request current notifications every time you return to the launcher, which means that all scripts will also get the `on_notifications_updated() callback called`. +Keep in mind that the AIO Launcher also request current notifications every time you return to the launcher, which means that all scripts will also get the `on_notifications_updated()` callback called. ## Files diff --git a/samples/image_sample.lua b/samples/image_sample.lua new file mode 100644 index 0000000..29b9185 --- /dev/null +++ b/samples/image_sample.lua @@ -0,0 +1,18 @@ +local height = 0 + +function on_load() + show_image() +end + +function on_click() + if height == 0 then + height = 100 + else + height = 0 + end + show_image() +end + +function show_image() + ui:show_image("https://dummyimage.com/600x400/000/fff", height) +end -- 2.43.0 From 296fbee02861c372c4c3de54a314a12ba906f3cc Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 3 May 2025 07:56:35 +0800 Subject: [PATCH 169/204] Add tags field to the apps table --- CHANGELOG.md | 14 ++++++++++++++ README.md | 19 +++++-------------- samples/apps-sample.lua | 2 +- samples/apps-sample2.lua | 8 ++++++++ 4 files changed, 28 insertions(+), 15 deletions(-) create mode 100644 samples/apps-sample2.lua diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c962ef..1222c29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +### 5.5.4 + +* Added `icon` meta tag +* Added `private_mode` meta tag +* Added `calendar:enabled_calendar_ids()` method + +### 5.5.1 + +* Added `calendar:is_holiday()` method + +### 5.5.0 + +* Added `aio:add_todo()` method + ### 5.3.5 * Added `ai` module diff --git a/README.md b/README.md index 9fb3bcd..5b86185 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,10 @@ The type of script is determined by the line (meta tag) at the beginning of the # Changelog +### 5.7.1 + +* Added `tags` field to the app table + ### 5.7.0 * Added `ui:show_image(uri)` method @@ -40,20 +44,6 @@ The type of script is determined by the line (meta tag) at the beginning of the * Added `ui:set_edit_mode_buttons()` method * Added size argument to `widgets:request_updates()` method -### 5.5.4 - -* Added `icon` meta tag -* Added `private_mode` meta tag -* Added `calendar:enabled_calendar_ids()` method - -### 5.5.1 - -* Added `calendar:is_holiday()` method - -### 5.5.0 - -* Added `aio:add_todo()` method - [Full changelog](CHANGELOG.md) # Widget scripts @@ -469,6 +459,7 @@ The format of the apps table: `hidden` - true if the application is hidden; `suspended` - true if the application is suspended; `category_id` - category ID; +`tags` - array of tags; `badge` - number on the badge; `icon` - icon of the application in the form of a link (can be used in the side menu scripts). ``` diff --git a/samples/apps-sample.lua b/samples/apps-sample.lua index 193e3bc..a67e046 100644 --- a/samples/apps-sample.lua +++ b/samples/apps-sample.lua @@ -2,7 +2,7 @@ all_apps = {} function on_resume() - all_apps = apps:get_list("launch_count") + all_apps = apps:list("launch_count") if (next(all_apps) == nil) then ui:show_text("The list of apps is not ready yet") diff --git a/samples/apps-sample2.lua b/samples/apps-sample2.lua new file mode 100644 index 0000000..579cc90 --- /dev/null +++ b/samples/apps-sample2.lua @@ -0,0 +1,8 @@ +-- Dumps app info table + +app_pkg = "com.android.calendar" + +function on_load() + local calendar_app = apps:app(app_pkg) + ui:show_text("%%txt%%"..serialize(calendar_app)) +end -- 2.43.0 From b9d73171edc877721adfcfd2fb6f61e66c2c16d1 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 3 May 2025 09:45:26 +0800 Subject: [PATCH 170/204] Cleanup samples --- samples/apps-sample.lua | 9 +- samples/apps-widget.lua | 360 ------------------ samples/bad-script.lua | 2 +- samples/bad-script8.lua | 2 +- samples/btc-widget.lua | 2 +- samples/calc.lua | 4 +- samples/calendar-sample.lua | 2 +- samples/clipboard-widget.lua | 2 +- samples/clipboard-widget2.lua | 2 +- samples/colors-sample.lua | 2 +- samples/conversations-widget.lua | 41 +- samples/currencies-widget.lua | 109 ------ samples/currency-search.lua | 71 ---- samples/currency-widget-ru.lua | 4 +- samples/drawer-sample.lua | 2 +- ...{drawer-sample3.lua => drawer-sample2.lua} | 2 +- samples/drawer-sample4.lua | 17 - samples/ip-location-widget.lua | 6 +- samples/lang-sample.lua | 2 +- samples/notes-widget.lua | 6 +- samples/perplexity-search.lua | 2 +- samples/place-widget.lua | 4 +- samples/shttp-text.lua | 4 +- samples/title-sample.lua | 2 +- samples/widgets-sample.lua | 2 +- samples/widgets-sample2.lua | 2 +- 26 files changed, 51 insertions(+), 612 deletions(-) delete mode 100644 samples/apps-widget.lua delete mode 100644 samples/currencies-widget.lua delete mode 100644 samples/currency-search.lua rename samples/{drawer-sample3.lua => drawer-sample2.lua} (92%) delete mode 100644 samples/drawer-sample4.lua diff --git a/samples/apps-sample.lua b/samples/apps-sample.lua index a67e046..eb61f93 100644 --- a/samples/apps-sample.lua +++ b/samples/apps-sample.lua @@ -2,7 +2,7 @@ all_apps = {} function on_resume() - all_apps = apps:list("launch_count") + all_apps = apps:apps("launch_count") if (next(all_apps) == nil) then ui:show_text("The list of apps is not ready yet") @@ -18,14 +18,13 @@ function on_resume() end function on_click(idx) - --apps:launch(all_apps[idx]) - apps:show_edit_dialog(all_apps[idx]) + apps:launch(all_apps[idx].pkg) end -- utils -function get_formatted_name(pkg) - return ""..apps:get_name(pkg).."" +function get_formatted_name(app) + return ""..app.name.."" end function table_to_tables(tab, num) diff --git a/samples/apps-widget.lua b/samples/apps-widget.lua deleted file mode 100644 index 91f6de0..0000000 --- a/samples/apps-widget.lua +++ /dev/null @@ -1,360 +0,0 @@ --- name = "My apps" --- description = "Simple apps widget" --- type = "widget" --- version = "1.0" --- author = "Andrey Gavrilov" - -local utf8 = require "utf8" -local dialog_id = "" -local app_idx = 0 - -function on_resume() - update_args() - local folding = false - if settings:get_kv()["folding"] == "true" then - folding = true - end - ui:set_folding_flag(folding) - redraw() -end - -function on_alarm() - local args = settings:get_kv() - if next(args) == nil then - args["no_hidden"] = true - args["columns"] = 4 - args["trim"] = 10 - args["folding"] = false - args["1"] = "com.android.settings" - settings:set_kv(args) - redraw() - end -end - -function on_settings() - dialog_id = "settings" - local tab = {"Applications list","No hidden setting","Columns number","Trim app name","Autofolding setting","Widget title"} - ui:show_radio_dialog("Settings",tab) -end - -function on_dialog_action(data) - if data == -1 then - return - end - if dialog_id == "settings" then - if data == 1 then - dialog_id = "apps" - local tab = get_all_apps("abc",settings:get_kv()["no_hidden"]) - ui:show_checkbox_dialog("Select apps",tab[2],args_to_idx(tab[1])) - return - elseif data == 2 then - dialog_id = "no_hidden" - local tab = {"Not show hidden applications"} - local tt = {} - if tostring(settings:get_kv()["no_hidden"]) == "true" then - tt = {1} - end - ui:show_checkbox_dialog("No hidden settings",tab,tt) - return - elseif data == 3 then - dialog_id = "columns" - ui:show_edit_dialog("Columns number","",settings:get_kv()["columns"]) - return - elseif data == 4 then - dialog_id = "trim" - ui:show_edit_dialog("Trim app name","0 - not trim",settings:get_kv()["trim"]) - return - elseif data == 5 then - dialog_id = "folding" - local tab = {"Autofolding"} - local tt = {} - if tostring(settings:get_kv()["folding"]) == "true" then - tt = {1} - end - ui:show_checkbox_dialog("Autofolding settings",tab,tt) - return - elseif data == 6 then - dialog_id = "name" - ui:show_edit_dialog("Set widget title","Empty - default title",ui:get_default_title()) - return - end - elseif dialog_id == "no_hidden" then - local args = settings:get_kv() - if next(data) == nil then - args["no_hidden"] = false - else - args["no_hidden"] = true - end - settings:set_kv(args) - update_args() - redraw() - return - elseif dialog_id == "apps" then - settings:set_kv(idx_to_args(data)) - redraw() - return - elseif dialog_id == "columns" then - if data == tostring(tonumber(data)) then - if tonumber(data) == 0 then - data = "1" - end - local args = settings:get_kv() - args["columns"] = math.floor(tonumber(data)) - settings:set_kv(args) - update_args() - redraw() - end - return - elseif dialog_id == "trim" then - if data == tostring(tonumber(data)) then - local args = settings:get_kv() - args["trim"] = math.floor(tonumber(data)) - settings:set_kv(args) - update_args() - redraw() - end - return - elseif dialog_id == "folding" then - local args = settings:get_kv() - if next(data) == nil then - args["folding"] = false - else - args["folding"] = true - end - settings:set_kv(args) - update_args() - redraw() - return - elseif dialog_id == "name" then - local title = ui:get_default_title() - if data ~= "" then - title = data - end - ui:set_title(title) - return - elseif dialog_id == "move" then - if data == tostring(tonumber(data)) then - local idx = math.floor(tonumber(data)) - local args = settings:get_kv() - if idx < 1 then - idx = 1 - elseif idx > max_key(args) then - idx = max_key(args) - end - local from = args[tostring(app_idx)] - local to = args[tostring(idx)] - args[tostring(app_idx)] = to - args[tostring(idx)] = from - settings:set_kv(args) - update_args() - redraw() - return - end - end -end - -function on_context_menu_click(idx) - if idx == 4 then - apps:show_edit_dialog(settings:get_kv()[tostring(app_idx)]) - elseif idx == 1 then - local args = settings:get_kv() - if app_idx == max_key(args) then - return - end - local from = args[tostring(app_idx)] - local to = args[tostring(app_idx+1)] - args[tostring(app_idx)] = to - args[tostring(app_idx+1)] = from - settings:set_kv(args) - update_args() - redraw() - return - elseif idx == 3 then - local args = settings:get_kv() - if app_idx == 1 then - return - end - local from = args[tostring(app_idx)] - local to = args[tostring(app_idx-1)] - args[tostring(app_idx)] = to - args[tostring(app_idx-1)] = from - settings:set_kv(args) - update_args() - redraw() - return - elseif idx == 2 then - local args = settings:get_kv() - local new_args = {} - for k,v in pairs(args) do - if k ~= tostring(app_idx) then - new_args[k] = v - end - end - settings:set_kv(new_args) - update_args() - redraw() - return - elseif idx == 5 then - dialog_id = "move" - local text = "Number from 1 to "..tostring(max_key(settings:get_kv())) - ui:show_edit_dialog("Set position",text,app_idx) - return - end -end - -function redraw() - local cols = tonumber(settings:get_kv()["columns"]) - if cols == 0 or cols == nil then - cols = 1 - end - ui:show_table(table_to_tables(tab_from_args(), cols)) -end - -function on_click(idx) - apps:launch(settings:get_kv()[tostring(idx)]) -end - -function on_long_click(idx) - app_idx = idx - ui:show_context_menu({ - { "chevron-right", "Forward" }, - { "times", "Remove" }, - { "chevron-left", "Back" }, - { "edit", "Edit" }, - { "exchange", "Move" } - }) -end - -function tab_from_args() - local args = settings:get_kv() - local len = tonumber(args["trim"]) - if len == nil then - len = 0 - end - local tab = {} - for k,v in pairs(args) do - if k == tostring(tonumber(k)) then - tab[tonumber(k)] = get_formatted_name(v,len) - end - end - return tab -end - -function get_formatted_name(pkg,len) - local str = apps:get_name(pkg) - if utf8.len(str) > len and len > 0 then - str = utf8.sub(str,1,len-1):gsub("[%. ]*$","").."." - end - return ""..str.."" -end - -function table_to_tables(tab, num) - local out_tab = {} - local row = {} - - for k,v in ipairs(tab) do - table.insert(row, v) - if k % num == 0 then - table.insert(out_tab, row) - row = {} - end - end - if row ~= {} then - table.insert(out_tab, row) - end - return out_tab -end - -function get_all_apps(sort_by,no_hidden) - if tostring(no_hidden) == "true" then - no_hidden = true - else - no_hidden = false - end - local t = settings:get_kv() - local all_apps = apps:get_list(sort_by,no_hidden) - local apps_names = {} - for k,v in ipairs(all_apps) do - apps_names[k] = apps:get_name(v) - end - return {all_apps,apps_names} -end - -function args_to_idx(tab) - local args = settings:get_kv() - local t = {} - for k,v in pairs(args) do - local idx = get_index(tab,v) - if idx > 0 then - table.insert(t,idx) - end - end - return t -end - -function idx_to_args(tab) - local args = settings:get_kv() - local all_apps = get_all_apps("abc",args["no_hidden"])[1] - local new_args = {} - for i,v in ipairs(tab) do - if get_key(args,all_apps[tonumber(v)]) == 0 then - new_args[tostring(max_key(args)+i)] = all_apps[tonumber(v)] - else - new_args[get_key(args,all_apps[tonumber(v)])] = all_apps[tonumber(v)] - end - end - new_args = sort_by_key(new_args) - new_args["no_hidden"] = args["no_hidden"] - new_args["columns"] = args["columns"] - new_args["trim"] = args["trim"] - new_args["folding"] = args["folding"] - return new_args -end - -function update_args() - local args = settings:get_kv() - local all_apps = get_all_apps("abc",args["no_hidden"])[1] - local new_args = {} - for k,v in pairs(args) do - if k == tostring(tonumber(k)) then - if get_index(all_apps,v) ~= 0 then - new_args[k] = v - end - end - end - new_args = sort_by_key(new_args) - new_args["no_hidden"] = args["no_hidden"] - new_args["columns"] = args["columns"] - new_args["trim"] = args["trim"] - new_args["folding"] = args["folding"] - settings:set_kv(new_args) -end - -function sort_by_key(tab) - local t = {} - local tt = {} - for k,v in pairs(tab) do - table.insert(t,tonumber(k)) - end - table.sort(t) - for i,v in ipairs(t) do - for kk,vv in pairs(tab) do - if kk == tostring(v) then - tt[tostring(i)] = vv - break - end - end - end - return tt -end - -function max_key(tab) - local t = {} - for k,v in pairs(tab) do - if k == tostring(tonumber(k)) then - table.insert(t,k) - end - end - table.sort(t) - return #t -end diff --git a/samples/bad-script.lua b/samples/bad-script.lua index 3e8c031..94068bb 100644 --- a/samples/bad-script.lua +++ b/samples/bad-script.lua @@ -6,6 +6,6 @@ end function on_click() while true do - system:copy_to_clipboard("http://google.com") + system:to_clipboard("http://google.com") end end diff --git a/samples/bad-script8.lua b/samples/bad-script8.lua index f04a31f..9799ca5 100644 --- a/samples/bad-script8.lua +++ b/samples/bad-script8.lua @@ -2,7 +2,7 @@ function on_resume() for i = 1, 15 do - system:copy_to_clipboard("aaa") + system:to_clipboard("aaa") ui:show_text(i) end end diff --git a/samples/btc-widget.lua b/samples/btc-widget.lua index b9c4968..b27aa29 100644 --- a/samples/btc-widget.lua +++ b/samples/btc-widget.lua @@ -11,6 +11,6 @@ function on_alarm() end function on_network_result(result) - local price = ajson:get_value(result, "object object:USD string:last") + local price = ajson:read(result, "object object:USD string:last") ui:show_text("1 BTC"..equals..price.." USD") end diff --git a/samples/calc.lua b/samples/calc.lua index 3034a6c..514cb6b 100644 --- a/samples/calc.lua +++ b/samples/calc.lua @@ -1,10 +1,10 @@ function on_alarm() - ui:show_text("Введите выражение") + ui:show_text("Enter an expression") end function on_click() - ui:show_edit_dialog("Введите выражение") + ui:show_edit_dialog("Enter an expression") end function on_dialog_action(text) diff --git a/samples/calendar-sample.lua b/samples/calendar-sample.lua index 5a66d9a..cf9b519 100644 --- a/samples/calendar-sample.lua +++ b/samples/calendar-sample.lua @@ -3,7 +3,7 @@ events = {} function on_resume() local ev_titles = {} - events = slice(calendar:get_events(), 1, 10) + events = slice(calendar:events(), 1, 10) for k,v in ipairs(events) do ev_titles[k] = v.title diff --git a/samples/clipboard-widget.lua b/samples/clipboard-widget.lua index 5dd9744..252b6be 100644 --- a/samples/clipboard-widget.lua +++ b/samples/clipboard-widget.lua @@ -5,6 +5,6 @@ -- version = "1.0" function on_resume() - local clipboard = system:get_from_clipboard() + local clipboard = system:clipboard() ui:show_text(clipboard) end diff --git a/samples/clipboard-widget2.lua b/samples/clipboard-widget2.lua index 050d063..4dc248e 100644 --- a/samples/clipboard-widget2.lua +++ b/samples/clipboard-widget2.lua @@ -3,5 +3,5 @@ function on_resume() end function on_click() - system:copy_to_clipboard("test", true) + system:to_clipboard("test", true) end diff --git a/samples/colors-sample.lua b/samples/colors-sample.lua index 328be81..f405148 100644 --- a/samples/colors-sample.lua +++ b/samples/colors-sample.lua @@ -1,5 +1,5 @@ function on_resume() - local colors = ui:get_colors() + local colors = aio:colors() local colors_strings = stringify_table(colors) ui:show_lines(colors_strings) diff --git a/samples/conversations-widget.lua b/samples/conversations-widget.lua index 13b2420..e7be381 100644 --- a/samples/conversations-widget.lua +++ b/samples/conversations-widget.lua @@ -3,33 +3,30 @@ -- author = "Evgeny Zobnin (zobnin@gmail.com)" -- version = "1.0" -local first_launch = true - local no_tab = {} local messages_tab = {} local keys_tab = {} local folded_string = "" function on_resume() - -- AIO Launcher will call get_current automatically on resume - if (first_launch) then - first_launch = false - notify:get_current() + update_notifications() +end + +function on_notifications_updated() + update_notifications() +end + +function update_notifications() + no_tab = {} + local notifications = notify:list() + + for _, n in pairs(notifications) do + -- Skip not clearable and non messenger notifications + if (n.is_clearable == true and table_size(n.messages) > 0) then + no_tab[n.key] = n + end end -end - -function on_notify_posted(n) - -- Skip not clearable and non messenger notifications - if (n.is_clearable == false) then return end - if (table_size(n.messages) == 0) then return end - - notify:consumed(n.key) - no_tab[n.key] = n - redraw() -end - -function on_notify_removed(n) - no_tab[n.key] = nil + redraw() end @@ -39,10 +36,10 @@ end function redraw() if (table_size(no_tab) == 0) then - aio:hide_widget() + ui:hide_widget() ui:show_text("Empty") else - aio:show_widget() + ui:show_widget() draw_ui() end end diff --git a/samples/currencies-widget.lua b/samples/currencies-widget.lua deleted file mode 100644 index 801eb3e..0000000 --- a/samples/currencies-widget.lua +++ /dev/null @@ -1,109 +0,0 @@ --- name = "Currencies" --- description = "Currency rates widget. Click on the date to change it." --- data_source = "github.com/fawazahmed0/currency-api#readme" --- type = "widget" --- author = "Andrey Gavrilov" --- version = "1.0" --- arguments_help = "Enter the list of currency pairs in the format usd:rub btc:usd" --- arguments_default = "usd:rub eur:rub" - -json = require "json" - --- constants -local red_color = "#f44336" -local green_color = "#48ad47" -local text_color = ui:get_colors().secondary_text -local equals = " = " - --- global vars -local result_curr = "" -local tabl = {} - -function on_resume() - ui:set_folding_flag(true) - ui:show_lines(tabl) -end - -function on_alarm() - get_rates("latest", "curr") -end - -function get_rates(loc_date,id) - http:get("https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/"..loc_date.."/currencies/usd.json",id) -end - -function on_network_result_curr(result) - result_curr = result - - local t = json.decode(result) - local dat = t.date - local prev_date = prev_date(dat) - - get_rates(prev_date, "prev") -end - -function on_network_result_prev(result) - tabl = create_tab(result) - ui:show_lines(tabl) -end - -function on_click(idx) - ui:show_edit_dialog("Enter the date", "Enter the date in the format 2020.12.31. A blank value is the current date.") -end - -function on_dialog_action(dat) - if dat == "" then dat = "latest" end - get_rates(dat:gsub(".", "-"), "curr") -end - -function prev_date(dat) - local prev_date = dat:split("-") - local prev_time = os.time{year=prev_date[1], month=prev_date[2], day=prev_date[3]} - (60*60*24) - return os.date("%Y-%m-%d", prev_time) -end - -function create_tab(result) - local curs = settings:get() - local tab = {} - local t_c = json.decode(result_curr) - local t_p = json.decode(result) - - -- set title - local dat = t_c.date - ui:set_title(ui:get_default_title().." "..dat:gsub("-", ".")) - - for idx = 1, #curs, 1 do - local cur = curs[idx]:split(":") - - local rate_curr1 = t_c.usd[cur[1]] - local rate_curr2 = t_c.usd[cur[2]] - local rate_prev1 = t_p.usd[cur[1]] - local rate_prev2 = t_p.usd[cur[2]] - - local rate_curr = round(rate_curr2/rate_curr1, 4) - local rate_prev = round(rate_prev2/rate_prev1, 4) - local change = round((rate_curr-rate_prev)/rate_prev*100,2) - - local line = "1 "..string.upper(cur[1])..equals..rate_curr.." "..string.upper(cur[2]) - line = line..get_formatted_change_text(change) - - table.insert(tab, line) - end - return tab -end - -function on_settings() - settings:show_dialog() -end - --- utils -- - -function get_formatted_change_text(change) - if change > 0 then - return " +"..change.."%" - elseif change < 0 then - return " "..change.."%" - else - return " "..change.."%" - end -end diff --git a/samples/currency-search.lua b/samples/currency-search.lua deleted file mode 100644 index 75631f1..0000000 --- a/samples/currency-search.lua +++ /dev/null @@ -1,71 +0,0 @@ --- name = "Exchange rates" --- description = "Shows currency rate by code" --- data_source = "https://api.exchangerate.host" --- type = "search" --- author = "Evgeny Zobbin & Andrey Gavrilov" --- version = "1.0" - --- modules -local json = require "json" -local md_color = require "md_colors" - --- constants -local host = "https://api.exchangerate.host" -local red = md_colors.red_500 -local base_currency = system:get_currency() - --- variables -local req_currency = "" -local req_amount = 1 -local result = 0 - -function on_search(inp) - req_currency = "" - req_amount = 1 - result = 0 - - local a,c = inp:match("^(%d*)%s?(%a%a%a)$") - if c == nil then return end - - req_currency = c:upper() - - if get_index(supported, req_currency) == 0 then - return - end - - if a ~= "" then - req_amount = a - end - - search:show({"Exchange rate for "..req_amount.." "..req_currency},{red}) -end - -function on_click() - if result == 0 then - http:get(host.."/convert?from="..req_currency.."&to="..base_currency.."&amount="..req_amount) - return false - else - system:copy_to_clipboard(result) - return true - end -end - -function on_long_click() - system:copy_to_clipboard(result) - return true -end - -function on_network_result(res) - local tab = json.decode(res) - - if tab.success then - search:show({tab.query.amount.." "..tab.query.from.." = "..tab.result.." "..tab.query.to}, {red}) - else - search:show({"No data"},{red}) - end -end - --- curl -s -XGET 'https://api.exchangerate.host/symbols?format=csv' | cut -d ',' -f 2 | grep -v code | sed 's/$/,/' | tr '\n' ' ' -supported = { - "AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BRL", "BSD", "BTC", "BTN", "BWP", "BYN", "BZD", "CAD", "CDF", "CHF", "CLF", "CLP", "CNH", "CNY", "COP", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GGP", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "IMP", "INR", "IQD", "IRR", "ISK", "JEP", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRO", "MRU", "MUR", "MVR", "MWK", "MXN", "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLL", "SOS", "SRD", "SSP", "STD", "STN", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "USD", "UYU", "UZS", "VEF", "VES", "VND", "VUV", "WST", "XAF", "XAG", "XAU", "XCD", "XDR", "XOF", "XPD", "XPF", "XPT", "YER", "ZAR", "ZMW", "ZWL", -} diff --git a/samples/currency-widget-ru.lua b/samples/currency-widget-ru.lua index 93215e3..79c9dc6 100644 --- a/samples/currency-widget-ru.lua +++ b/samples/currency-widget-ru.lua @@ -8,7 +8,7 @@ local json = require "json" local color = require "md_colors" -local text_color = ui:get_colors().secondary_text +local text_color = aio:colors().secondary_text local equals = " = " -- константы -- @@ -50,7 +50,7 @@ function on_network_result(result) line = amount.." "..string.upper(cur).." "..equals.." "..divide_number(rate," ").." "..string.upper(base_cur)..get_formatted_change_text(change) tab = {{"ᐊ", amount, string.upper(cur), equals, divide_number(rate," "), string.upper(base_cur), get_formatted_change_text(change), "ᐅ"}} ui:show_table(tab, 7) - ui:set_title(ui:get_default_title().." ("..date:gsub("(%d+)-(%d+)-(%d+)", "%3.%2.%1")..")") + ui:set_title(ui:default_title().." ("..date:gsub("(%d+)-(%d+)-(%d+)", "%3.%2.%1")..")") end function on_click(idx) diff --git a/samples/drawer-sample.lua b/samples/drawer-sample.lua index 96c3e10..f1d19bd 100644 --- a/samples/drawer-sample.lua +++ b/samples/drawer-sample.lua @@ -1,4 +1,4 @@ --- name = "Drawer Sample" +-- name = "Drawer Sample #1" -- type = "drawer" -- testing = "true" diff --git a/samples/drawer-sample3.lua b/samples/drawer-sample2.lua similarity index 92% rename from samples/drawer-sample3.lua rename to samples/drawer-sample2.lua index 30083ee..ae0c269 100644 --- a/samples/drawer-sample3.lua +++ b/samples/drawer-sample2.lua @@ -1,4 +1,4 @@ --- name = "Drawer Sample #3" +-- name = "Drawer Sample #2" -- type = "drawer" -- testing = "true" diff --git a/samples/drawer-sample4.lua b/samples/drawer-sample4.lua deleted file mode 100644 index 4836870..0000000 --- a/samples/drawer-sample4.lua +++ /dev/null @@ -1,17 +0,0 @@ --- name = "Drawer sample #4" --- type = "drawer" --- testing = "true" - -function on_drawer_open() - pkgs = apps:list() - apps:request_icons(pkgs) -end - -function on_icons_ready(icons) - names = map(function(it) return apps:name(it) end, pkgs) - drawer:show_list(names, icons, nil, true) -end - -function on_click(idx) - apps:launch(pkgs[idx]) -end diff --git a/samples/ip-location-widget.lua b/samples/ip-location-widget.lua index 9a7a245..acba692 100644 --- a/samples/ip-location-widget.lua +++ b/samples/ip-location-widget.lua @@ -7,14 +7,14 @@ end function on_network_result_ip(result) local location = { - ajson:get_value(result, "object string:latitude"), - ajson:get_value(result, "object string:longitude") + ajson:read(result, "object string:latitude"), + ajson:read(result, "object string:longitude") } http:get(addr_service_url.."&lat="..location[1].."&lon=".. location[2].."&addressdetails=1", "addr") end function on_network_result_addr(result) - local adr = ajson:get_value(result, "object string:display_name") + local adr = ajson:read(result, "object string:display_name") ui:show_text(adr) end diff --git a/samples/lang-sample.lua b/samples/lang-sample.lua index e4702e8..704ef33 100644 --- a/samples/lang-sample.lua +++ b/samples/lang-sample.lua @@ -1,3 +1,3 @@ function on_resume() - ui:show_text("Phone language: "..system:get_lang()) + ui:show_text("Phone language: "..system:lang()) end diff --git a/samples/notes-widget.lua b/samples/notes-widget.lua index 6ddbc70..e7dea5b 100644 --- a/samples/notes-widget.lua +++ b/samples/notes-widget.lua @@ -22,7 +22,7 @@ function on_alarm() table.insert(buttons,button) table.insert(colors,v.color) end - local color = ui:get_colors() + local color = aio:colors() table.insert(buttons,"+") table.insert(colors,color.secondary_text) ui:show_buttons(buttons,colors) @@ -44,7 +44,7 @@ function on_dialog_action(data) if data ~= -1 then if diag_id == "new" then if data ~= "" then - local color = ui:get_colors() + local color = aio:colors() local note = {} note.text = data note.color = color.button @@ -85,7 +85,7 @@ end function on_context_menu_click(idx) local md_color = require "md_colors" - local color = ui:get_colors() + local color = aio:colors() if idx == 1 then move(-1) elseif idx == 2 then diff --git a/samples/perplexity-search.lua b/samples/perplexity-search.lua index f466062..b6d23ad 100644 --- a/samples/perplexity-search.lua +++ b/samples/perplexity-search.lua @@ -16,7 +16,7 @@ local green = md_colors.green_400 function on_search(input) text_from = input text_to = "" - search:show({input},{green}) + search:show_lines({input},{green}) end function on_click(idx) diff --git a/samples/place-widget.lua b/samples/place-widget.lua index aecc0a4..ba77c94 100644 --- a/samples/place-widget.lua +++ b/samples/place-widget.lua @@ -1,9 +1,9 @@ function on_alarm() - local location = system:get_location() + local location = system:location() http:get("https://nominatim.openstreetmap.org/reverse?format=json&lat=".. location[1].."&lon=".. location[2].."&addressdetails=1") end function on_network_result(result) - local adr = ajson:get_value(result, "object string:display_name") + local adr = ajson:read(result, "object string:display_name") ui:show_text(adr) end diff --git a/samples/shttp-text.lua b/samples/shttp-text.lua index da91fbc..c7515d2 100644 --- a/samples/shttp-text.lua +++ b/samples/shttp-text.lua @@ -14,13 +14,13 @@ function on_alarm() end if response.code >= 200 and response.code < 300 then - joke = ajson:get_value(response.body, "object object:value string:joke") + joke = ajson:read(response.body, "object object:value string:joke") ui:show_text(joke) end end function on_click() if joke ~= nil then - system:copy_to_clipboard(joke) + system:to_clipboard(joke) end end diff --git a/samples/title-sample.lua b/samples/title-sample.lua index 8db6efa..ca0f52d 100644 --- a/samples/title-sample.lua +++ b/samples/title-sample.lua @@ -1,4 +1,4 @@ function on_resume() ui:set_title("New title") - ui:show_text("Original title: "..ui:get_default_title()) + ui:show_text("Original title: "..ui:default_title()) end diff --git a/samples/widgets-sample.lua b/samples/widgets-sample.lua index a4b5e1e..e04c25f 100644 --- a/samples/widgets-sample.lua +++ b/samples/widgets-sample.lua @@ -1,7 +1,7 @@ local fmt = require "fmt" function on_resume() - local widgets = aio:get_active_widgets() + local widgets = aio:active_widgets() local tab = {} for k,v in pairs(widgets) do diff --git a/samples/widgets-sample2.lua b/samples/widgets-sample2.lua index ad9182a..0267471 100644 --- a/samples/widgets-sample2.lua +++ b/samples/widgets-sample2.lua @@ -1,7 +1,7 @@ local fmt = require "fmt" function on_resume() - local widgets = aio:get_available_widgets() + local widgets = aio:available_widgets() local tab = {} for k,v in pairs(widgets) do -- 2.43.0 From d68ab0934f7d1c308c49f5e40b9def96fbaee2de Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 3 May 2025 10:14:22 +0800 Subject: [PATCH 171/204] Cleanup main scripts --- main/calendar.lua | 6 +++--- main/facts-widget.lua | 4 ++-- main/unit-converter.lua | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/main/calendar.lua b/main/calendar.lua index 893a751..cbde23d 100644 --- a/main/calendar.lua +++ b/main/calendar.lua @@ -116,7 +116,7 @@ function on_dialog_action(data) end function get_cal(y,m) - local color = ui:colors() + local color = aio:colors() local events = get_my_events(y,m,0) local from = os.time{year=y,month=m,day=1} local tab = { @@ -151,7 +151,7 @@ function get_cal(y,m) end function format_day(y,m,d,events) - local color = ui:colors() + local color = aio:colors() local from = os.time{year=y,month=m,day=d,hour=0,min=0,sec=0} local to = os.time{year=y,month=m,day=d,hour=23,min=59,sec=59} local yes = false @@ -261,7 +261,7 @@ function get_day_tab(events) end function get_lines(events) - local color = ui:colors() + local color = aio:colors() local lines = {} for i,v in ipairs(events) do table.insert(lines,"") diff --git a/main/facts-widget.lua b/main/facts-widget.lua index 396c493..8f79205 100644 --- a/main/facts-widget.lua +++ b/main/facts-widget.lua @@ -12,13 +12,13 @@ end function on_network_result(result, code) if code >= 200 and code < 299 then - text = ajson:get_value(result, "object string:text") + text = ajson:read(result, "object string:text") ui:show_lines{ text } end end function on_click() if text ~= nil then - system:copy_to_clipboard(text) + system:to_clipboard(text) end end diff --git a/main/unit-converter.lua b/main/unit-converter.lua index 9ee72b8..20d25f2 100644 --- a/main/unit-converter.lua +++ b/main/unit-converter.lua @@ -18,7 +18,7 @@ function on_alarm() end function redraw() - local color = ui:colors() + local color = aio:colors() if unit == "temperature" then sum = round(f[units[unit][unit_from]..units[unit][unit_to]](amount),3) else -- 2.43.0 From 82ce7e6eff4346b5aa19851b99718232a7abcde3 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 3 May 2025 12:56:03 +0800 Subject: [PATCH 172/204] Cleanup community scripts --- community/currency-cbr-search.lua | 6 +++--- community/dad-jokes-widget.lua | 4 ++-- community/google-translate-search.lua | 10 +++++----- community/google-translate-widget.lua | 2 +- community/navigate-search.lua | 2 +- community/password-gen-search.lua | 4 ++-- community/public-ip-search.lua | 6 +++--- community/quickactions-widget.lua | 2 +- community/random-joke-widget.lua | 6 +++--- community/region-ru-search.lua | 2 +- community/share-menu-search.lua | 2 +- 11 files changed, 23 insertions(+), 23 deletions(-) diff --git a/community/currency-cbr-search.lua b/community/currency-cbr-search.lua index 2698919..6f0d7ba 100644 --- a/community/currency-cbr-search.lua +++ b/community/currency-cbr-search.lua @@ -47,7 +47,7 @@ function on_click() http:get("https://www.cbr.ru/scripts/XML_daily.asp?date_req="..dat:replace("%.","/")) return false else - system:copy_to_clipboard(val) + system:to_clipboard(val) return true end end @@ -61,10 +61,10 @@ function on_network_result(res) return end end - search:show({"Нет данных по валюте "..cur},{red}) + search:show_buttons({"Нет данных по валюте "..cur},{red}) end function on_long_click() - system:copy_to_clipboard(val) + system:to_clipboard(val) return true end diff --git a/community/dad-jokes-widget.lua b/community/dad-jokes-widget.lua index 2127b6c..e4ef4f4 100644 --- a/community/dad-jokes-widget.lua +++ b/community/dad-jokes-widget.lua @@ -9,12 +9,12 @@ function on_resume() end function on_network_result(result) - joke = ajson:get_value(result, "object array:attachments object:0 string:text") + joke = ajson:read(result, "object array:attachments object:0 string:text") ui:show_text(joke) end function on_click() if joke ~= nil then - system:copy_to_clipboard(joke) + system:to_clipboard(joke) end end diff --git a/community/google-translate-search.lua b/community/google-translate-search.lua index a40174a..1d08ec5 100644 --- a/community/google-translate-search.lua +++ b/community/google-translate-search.lua @@ -21,7 +21,7 @@ function on_search(input) text_from = input text_to = "" - search:show_top({"Translate \""..input.."\""}, {blue}) + search:show_buttons({"Translate \""..input.."\""}, {blue}, true) end function on_click() @@ -30,20 +30,20 @@ function on_click() request_trans(text_from) return false else - system:copy_to_clipboard(text_to) + system:to_clipboard(text_to) return true end end function request_trans(str) - http:get(uri.."&tl="..system:get_lang().."&dt=t&q="..str) + http:get(uri.."&tl="..system:lang().."&dt=t&q="..str) end function on_network_result(result, code) if code >= 200 and code < 300 then decode_and_show(result) else - search:show_top({"Server error"}, {red}) + search:show_buttons({"Server error"}, {red}, true) end end @@ -57,7 +57,7 @@ function decode_and_show(result) --local lang_from = t[3] if text_to ~= "" then - search:show_top({text_to}, {blue}) + search:show_buttons({text_to}, {blue}, true) end end diff --git a/community/google-translate-widget.lua b/community/google-translate-widget.lua index 038f2ad..52d3112 100644 --- a/community/google-translate-widget.lua +++ b/community/google-translate-widget.lua @@ -26,7 +26,7 @@ function on_dialog_action(text) end function translate(str) - http:get(uri.."&tl="..system:get_lang().."&dt=t&q="..str) + http:get(uri.."&tl="..system:lang().."&dt=t&q="..str) end function on_network_result(result) diff --git a/community/navigate-search.lua b/community/navigate-search.lua index 432aa8c..342e077 100644 --- a/community/navigate-search.lua +++ b/community/navigate-search.lua @@ -18,7 +18,7 @@ local blue = md_colors.light_blue_800 function on_search(input) text_from = input text_to = "" - search:show({input},{blue}) + search:show_buttons({input},{blue}) end function on_click(idx) diff --git a/community/password-gen-search.lua b/community/password-gen-search.lua index 066b302..93fa432 100644 --- a/community/password-gen-search.lua +++ b/community/password-gen-search.lua @@ -8,7 +8,7 @@ local pass = "" function on_search(str) if str:lower():find(string.lower("password")) then pass = gen_pass() - search:show{pass} + search:show_buttons{pass} end end @@ -26,5 +26,5 @@ function gen_pass() end function on_click() - system:copy_to_clipboard(pass) + system:to_clipboard(pass) end diff --git a/community/public-ip-search.lua b/community/public-ip-search.lua index febd5b2..3a14085 100644 --- a/community/public-ip-search.lua +++ b/community/public-ip-search.lua @@ -17,7 +17,7 @@ function on_search(input) end function on_click() - system:copy_to_clipboard(ip) + system:to_clipboard(ip) end function get_ip() @@ -27,9 +27,9 @@ end function on_network_result(result,code) if code >= 200 and code < 300 then ip = result - search:show({result},{blue}) + search:show_buttons({result},{blue}) else - search:show({"Server Error"},{red}) + search:show_buttons({"Server Error"},{red}) end end diff --git a/community/quickactions-widget.lua b/community/quickactions-widget.lua index 0c0ddd2..7fb35c1 100644 --- a/community/quickactions-widget.lua +++ b/community/quickactions-widget.lua @@ -14,7 +14,7 @@ local names = {"Quick menu", "Quick apps menu", "Applications menu", "Toggle hea local colors = { md_colors.purple_800, md_colors.purple_600, md_colors.amber_900, md_colors.orange_900, md_colors.blue_900, md_colors.deep_purple_800, md_colors.grey_600, md_colors.green_900, md_colors.green_900, md_colors.blue_800, md_colors.pink_300, md_colors.pink_A200, md_colors.green_600, md_colors.grey_800, md_colors.teal_700, md_colors.teal_800, md_colors.orange_700, md_colors.red_800, md_colors.red_900, md_colors.deep_purple_700, md_colors.blue_700, md_colors.amber_800, md_colors.blue_grey_700} - local actions = { "quick_menu", "quick_apps_menu", "apps_menu", "headers", "settings", "refresh", "restart", "notify", "clear_notifications", "quick_settings", "fold", "unfold", "private_mode", "screen_off", "scroll_down", "scroll_up", "add_note", "start_record", "send_mail", "show_recents", "voice", "one_handed", "search"} +local actions = { "quick_menu", "quick_apps_menu", "apps_menu", "headers", "settings", "refresh", "restart", "notify", "clear_notifications", "quick_settings", "fold", "unfold", "private_mode", "screen_off", "scroll_down", "scroll_up", "add_note", "start_record", "send_mail", "show_recents", "voice", "one_handed", "search"} local pos = 0 diff --git a/community/random-joke-widget.lua b/community/random-joke-widget.lua index 64fdc2a..eb7af65 100644 --- a/community/random-joke-widget.lua +++ b/community/random-joke-widget.lua @@ -10,14 +10,14 @@ function on_alarm() end function on_network_result(result) - setup = ajson:get_value(result, "object string:setup") - punchline = ajson:get_value(result, "object string:punchline") + setup = ajson:read(result, "object string:setup") + punchline = ajson:read(result, "object string:punchline") ui:show_lines({setup, punchline}) end function on_click() if setup ~= nil then - system:copy_to_clipboard(setup.."\n"..punchline) + system:to_clipboard(setup.."\n"..punchline) end end diff --git a/community/region-ru-search.lua b/community/region-ru-search.lua index 491118e..70510fb 100644 --- a/community/region-ru-search.lua +++ b/community/region-ru-search.lua @@ -10,7 +10,7 @@ function on_search(str) local region = codes[code] if region ~= nil then - search:show{code.." - "..region} + search:show_buttons{code.." - "..region} end end diff --git a/community/share-menu-search.lua b/community/share-menu-search.lua index b58cea4..1c76d75 100644 --- a/community/share-menu-search.lua +++ b/community/share-menu-search.lua @@ -18,7 +18,7 @@ text_to="" function on_search(input) text_from = input text_to = "" - search:show({"Share \""..input.."\""}, {blue}) + search:show_buttons({"Share \""..input.."\""}, {blue}, true) end function on_click() -- 2.43.0 From 6cdb5a9336d7507d715a5619232d08f141daed18 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 3 May 2025 13:20:09 +0800 Subject: [PATCH 173/204] Add sample created by Cursor --- samples/top-apps-widget.lua | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 samples/top-apps-widget.lua diff --git a/samples/top-apps-widget.lua b/samples/top-apps-widget.lua new file mode 100644 index 0000000..f95ca7a --- /dev/null +++ b/samples/top-apps-widget.lua @@ -0,0 +1,33 @@ +-- name = "Top Apps" +-- icon = "fa:star" +-- description = "Shows 10 most frequently used applications" +-- type = "widget" +-- foldable = "true" + +-- Created in Cursor +-- Original prompt: "Read README and script examples and write a widget script that will display 10 most used applications." + +function on_resume() + -- Get list of applications sorted by launch count + local apps = apps:apps("launch_count") + + -- Create table for display + local lines = {} + for i = 1, 10 do + if apps[i] then + -- Add number and application name + table.insert(lines, i .. ". " .. apps[i].name) + end + end + + -- Display the list + ui:show_lines(lines) +end + +-- Handle application click +function on_click(index) + local apps = apps:apps("launch_count") + if apps[index] then + apps:launch(apps[index].pkg) + end +end \ No newline at end of file -- 2.43.0 From d7cd1c7f26ea44e72f40226f637b9a4f9c13e060 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 3 May 2025 14:38:33 +0800 Subject: [PATCH 174/204] Add tides script --- community/tide-widget.lua | 114 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 community/tide-widget.lua diff --git a/community/tide-widget.lua b/community/tide-widget.lua new file mode 100644 index 0000000..9002064 --- /dev/null +++ b/community/tide-widget.lua @@ -0,0 +1,114 @@ +-- name = "Tide Time" +-- description = "Widget shows high and low tide times for today." +-- data_source = "https://open-meteo.com/en/docs/marine-weather-api" +-- type = "widget" +-- author = "AI Assistant" +-- version = "1.0" + +local json = require "json" +local color = require "md_colors" +local text_color = aio:colors().secondary_text + +-- variables +local tide_data = nil +local tide_times = {} + +function on_alarm() + get_tide_data() +end + +function get_tide_data() + local today = os.date("%Y-%m-%d") + local location = system:location() + local url = string.format( + "https://marine-api.open-meteo.com/v1/marine?latitude=%f&longitude=%f&hourly=sea_level_height_msl&timezone=auto&start_date=%s&end_date=%s", + location[1], location[2], today, today + ) + http:get(url) +end + +function on_network_result(result) + local data = json.decode(result) + if not data or not data.hourly then + ui:show_toast("Error getting data: " .. (result or "no response")) + return + end + + tide_data = data + process_tide_data() + display_tide_times() +end + +function process_tide_data() + tide_times = {} + local times = tide_data.hourly.time + local heights = tide_data.hourly.sea_level_height_msl + + if not times or not heights then + ui:show_text("Invalid data format") + return + end + + -- Find local maxima and minima + for i = 2, #heights - 1 do + if heights[i] > heights[i-1] and heights[i] > heights[i+1] then + table.insert(tide_times, { + time = times[i], + height = heights[i], + type = "high tide" + }) + elseif heights[i] < heights[i-1] and heights[i] < heights[i+1] then + table.insert(tide_times, { + time = times[i], + height = heights[i], + type = "low tide" + }) + end + end +end + +function display_tide_times() + if #tide_times == 0 then + ui:show_text("No tide data available") + return + end + + local tab = {} + for _, tide in ipairs(tide_times) do + local time = tide.time:match("T(%d+:%d+)") + local height = string.format("%.2f", tide.height) + local type = tide.type + local color = type == "high tide" and color.blue_500 or color.blue_900 + + table.insert(tab, { + string.format("%s", color, type), + time, + height .. " m" + }) + end + + ui:show_table(tab, 3) + ui:set_title(ui:default_title() .. " (" .. os.date("%d.%m.%Y") .. ")") +end + +function on_long_click(idx) + ui:show_context_menu({ + {"redo", "Refresh"}, + {"copy", "Copy data"} + }) +end + +function on_context_menu_click(menu_idx) + if menu_idx == 1 then + get_tide_data() + ui:show_toast("Updating data...") + elseif menu_idx == 2 then + local text = "Tide times for " .. os.date("%d.%m.%Y") .. ":\n" + for _, tide in ipairs(tide_times) do + local time = tide.time:match("T(%d+:%d+)") + text = text .. string.format("%s: %s (%.2f m)\n", tide.type, time, tide.height) + end + system:copy_to_clipboard(text) + ui:show_toast("Data copied") + end +end \ No newline at end of file -- 2.43.0 From 26ebaa302036f0ba8bd711c303d06f68f6d2d4d2 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 5 May 2025 08:35:59 +0800 Subject: [PATCH 175/204] Add system:tz() --- README.md | 2 ++ samples/tz-sample.lua | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 samples/tz-sample.lua diff --git a/README.md b/README.md index 5b86185..e36a3a5 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ The type of script is determined by the line (meta tag) at the beginning of the ### 5.7.1 * Added `tags` field to the app table +* Added `system:tz()` method ### 5.7.0 @@ -327,6 +328,7 @@ The function takes a command table of this format as a parameter: * `system:alarm_sound(seconds)` - make alarm sound; * `system:share_text(string)` - opens the "Share" system dialog; * `system:lang()` - returns the language selected in the system; +* `system:tz()` - returns TimeZone string (example: Africa/Cairo); * `system:tz_offset()` - returns TimeZone offset in seconds; * `system:currency()` - returns default currency code based on locale; * `system:format_date_localized(format, date)` - returns localized date string (using java formatting); diff --git a/samples/tz-sample.lua b/samples/tz-sample.lua new file mode 100644 index 0000000..52f39ef --- /dev/null +++ b/samples/tz-sample.lua @@ -0,0 +1,6 @@ +function on_load() + ui:show_lines{ + "Time zone: "..system:tz(), + "Offset in seconds: "..system:tz_offset() + } +end -- 2.43.0 From 3aff6de786be8be7a863d3bcf42dec2e51a609ae Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 10 May 2025 14:22:54 +0800 Subject: [PATCH 176/204] Cleanup ru scripts --- ru/currency-ru-widget.lua | 4 ++-- ru/isdayoff-ru-widget.lua | 4 ++-- ru/quotes-ru-widget.lua | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ru/currency-ru-widget.lua b/ru/currency-ru-widget.lua index 1c379f9..e837d96 100644 --- a/ru/currency-ru-widget.lua +++ b/ru/currency-ru-widget.lua @@ -69,7 +69,7 @@ end function on_network_result_history(result,error) history = "" - local color = ui:get_colors() + local color = aio:colors() local equals = " = " local xml = require "xml" local t = xml:parse(result) @@ -111,7 +111,7 @@ function get_rates() end function get_formatted_change_text(change) - local color = ui:get_colors() + local color = aio:colors() if change > 0 then return " +"..change.."%" elseif change < 0 then diff --git a/ru/isdayoff-ru-widget.lua b/ru/isdayoff-ru-widget.lua index 4ec70e6..c5ba832 100644 --- a/ru/isdayoff-ru-widget.lua +++ b/ru/isdayoff-ru-widget.lua @@ -7,8 +7,8 @@ -- version = "1.0" function on_alarm() - local dateStr = os.date('%Y%m%d') - http:get("https://isdayoff.ru/"..dateStr) + local dateStr = os.date('%Y%m%d') + http:get("https://isdayoff.ru/"..dateStr) end function on_network_result(result) diff --git a/ru/quotes-ru-widget.lua b/ru/quotes-ru-widget.lua index 96ad088..1366e3c 100644 --- a/ru/quotes-ru-widget.lua +++ b/ru/quotes-ru-widget.lua @@ -11,14 +11,14 @@ function on_alarm() end function on_network_result(result) - quote = ajson:get_value(result, "object string:quoteText") - author = ajson:get_value(result, "object string:quoteAuthor") + quote = ajson:read(result, "object string:quoteText") + author = ajson:read(result, "object string:quoteAuthor") ui:show_lines({ quote }, { author }) end function on_click() if quote ~= nil then - system:copy_to_clipboard(quote) + system:to_clipboard(quote) end end -- 2.43.0 From 3b948cc4ca20a23a9d6a308ab4090fe522a0162e Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 12 May 2025 06:04:27 +0800 Subject: [PATCH 177/204] Update scripts.zip --- scripts.md5 | 2 +- scripts.zip | Bin 18545 -> 18528 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts.md5 b/scripts.md5 index 8b1a7b7..4c823cb 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -b0140e81bebb47aa36f22dcbeb809a3e +ec2a956ff165ea7388db1aa8bcf0eafa diff --git a/scripts.zip b/scripts.zip index 8291911b198f84577dd921e24dd0603df1ecee1c..f475444e4c50b1456707d77036adca406a96cb06 100644 GIT binary patch delta 8596 zcmZvBWmH^Cv-S)yxVyW%ySrPE;O_3uV8ID85C|GHxI=IV!GZ^ZI|KnYGbEQ z`O*3H;{mXuc(@+-h&0t)p@cvYk`K=b-o4CMM~y?Y(TguC5{9Nz6*kHBP>8-=ie}v) zL~=kphC`yx@j#(HYc5~+Z#(Nbhv~Z(MCiPy=b9pQ_b%JR*livo=hKOt2E4vx-iTR{ zw_1QbCbz`M`o5Tc^Hron4q|Zyx7erl(KDh}Ebp?GzQd&JFd&ghJC-yNK(&_*#sXC? z3KiB5e=mH^x~UJ9=EX)Ns-6n-1h;B@CCc4gtnP-0W`EdB{z|iO(PecDO$0;Tu`7xq z{1?JELrjBENhK1Sxi)^RSaR)FjBgU;Hf60#@Rzn+JVrH}byHpIyAeO-^=V65>x(#X z?L=o766r>!mt}iaq!prb47QAe7u!eWkb^?D!kxP4Jd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k@I<|7HEBRUZan7o!IMuU!0p^yJet z<`f1wa04%O!v^#aTGu`xNSpkIF8EnC#OD<1#FgUVE>=Z}jPo02Slrd!Li2kM)e{Y* zd4TV_UjpQRDJuBzxKGl|m6*MXQcrAhq4u7`#DC{(Ybb=YF`j~>!6?LbS2i$Zf06KbrL0qAwR_^!B`ErL{{{!B1%|9 zq1=8d98eo+E${81+{k5`ZS@~9IX^tiq6yXQ($Ymc>ZXQqMAlpxpwBW_U`@q~cu=E? z?uWQ_S?@Nh^Xyoo=;_f96;_n_);;ZXd-;C~ZzX}{4UM3|zD%b9#xZmv675*Abxmk3 zxu&IE>(-809@7XM5n8>1H$TP!vUf1YCVzjAwW`G37`uI`%ub+EUs)w_-Q{+`AxUeTQWtfjj-1AW(WXk(Y6BA|b&}p`R{=v@v=Grd(r^Si`fP~;sLVih0K%qf|W%QwxA!#z&P>YaLnGaB=5CvI1Xc#g` zsVtAszfc`=000~C-^JBY0sx-Qb{?!2F3w(7AP+0hKVaP-fnJbTX>tgM961yNL{&~7 zhJXzKVPhkKjL1<_{HvsA2LSN@#ncRf@SYs@ulM|y!V-UlqDfnE(wjdgwE2Vi{d@De zFaTid;^=E>=IhQ1^86QM_(zLB;VVUk^lyRxJ8u2)n}745fb{-1fq!rQx0C(%BQHWo SfTaIuCk&*3@09%O^8X9ETSNo^ -- 2.43.0 From 95d8ed99ee67acf56fff09a06b86bd29de914d73 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 20 May 2025 14:43:54 +0800 Subject: [PATCH 178/204] Small fix to Google translate search script --- community/google-translate-search.lua | 2 +- samples/deprecated-sample.lua | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 samples/deprecated-sample.lua diff --git a/community/google-translate-search.lua b/community/google-translate-search.lua index 1d08ec5..423b96b 100644 --- a/community/google-translate-search.lua +++ b/community/google-translate-search.lua @@ -26,7 +26,7 @@ end function on_click() if text_to == "" then - search:show_top({"Translating..."}, {blue}) + search:show_buttons({"Translating..."}, {blue}, true) request_trans(text_from) return false else diff --git a/samples/deprecated-sample.lua b/samples/deprecated-sample.lua new file mode 100644 index 0000000..a64cc65 --- /dev/null +++ b/samples/deprecated-sample.lua @@ -0,0 +1,4 @@ +function on_resume() + ui:get_default_title() -- deprecated function + ui:show_text("Test") +end -- 2.43.0 From 9a9e21a53d2386e8e9731d898dc23b38aa888c8e Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 20 May 2025 14:44:18 +0800 Subject: [PATCH 179/204] Update scripts.zip --- scripts.md5 | 2 +- scripts.zip | Bin 18528 -> 18528 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts.md5 b/scripts.md5 index 4c823cb..3e658dc 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -ec2a956ff165ea7388db1aa8bcf0eafa +75d35325b380ccd55a2f8b34187a5ab1 diff --git a/scripts.zip b/scripts.zip index f475444e4c50b1456707d77036adca406a96cb06..d3b8d38b76e5dd3e52cc42c6632ffa6077f3c54f 100644 GIT binary patch delta 177 zcmaDbf$_lv#tD|pUMe~pZ4NSm=uJ#{oFIC0A$JWEnDK#kGKA44&<9qsSzKr$gt1z9 z287`zY6)R9i9yu}OEfWqwa<{A4UsaFT>}w$s!+iNmP*k605LgO&lRF(wtfW?GVZV08H61D*ylh delta 177 zcmaDbf$_lv#tD|peR7H$Z4NSm=uJ#{oFIC0A$JWEnDK#kGKA44&<9qsSzKr$gt1z9 z287`zY6)R9i9yu}OEfWqwa<{A4UsaFT>}w$s!+iNmP*k605LgO&lRF(wtfW?GVZV0G~uN^Z)<= -- 2.43.0 From aa215947c9f1bc14a892974d25491ea94ae90f86 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 29 May 2025 06:46:33 +0800 Subject: [PATCH 180/204] Small README fix --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e36a3a5..3089938 100644 --- a/README.md +++ b/README.md @@ -452,7 +452,7 @@ end * `apps:show_edit_dialog(package)` - shows edit dialog of the application; * `apps:categories()` - returns a table of category tables. -The format of the apps table: +The format of the app table: ``` `pkg` - name of the app package (if it is cloned app or Android for Work app package name will also contain user id, like that: `com.example.app:123`); @@ -806,7 +806,7 @@ _Avaialble from: 4.4.4_ * `tasker:tasks([project])` - returns a list of all the tasks in the Tasker, the second optional argument is the project for which you want to get the tasks (returns nil if Tasker is not installed or enabled); * `tasker:projects()` - returns all Tasker projects (returns nil if Tasker is not installed or enabled); -* `tasker:run_task(name, [args])` - executes the task in the Tasker, the second optional argument is a table of variables passed to the task in the format `{ "name" = "value" }`; +* `tasker:run_task(name, [args])` - executes the task in the Tasker, the second optional argument is a table of variables passed to the task in the format `{ name = "value" }`; * `tasker:run_own_task(commands)` - constructs and performs the task on the fly; * `tasker:send_command(command)` - sends [tasker command](https://tasker.joaoapps.com/commandsystem.html). -- 2.43.0 From 2ab316efd6200e5d36f5bf168d1a1842d8ea54a2 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 5 Jun 2025 17:05:34 +0800 Subject: [PATCH 181/204] Replace deprecated functions in many scripts --- community/amdroid-nextalarm-app-widget.lua | 4 ++-- community/birthdays-widget.lua | 4 ++-- community/calllog-ru-root-widget.lua | 4 ++-- community/fifteen-widget.lua | 4 ++-- community/google-search-app-widget.lua | 12 ++++++------ community/google-translate-widget.lua | 4 ++-- community/quickactions-widget.lua | 12 ++++++------ community/tvguide-ru-widget.lua | 6 +++--- community/widgets-on-off.lua | 4 ++-- main/calendar.lua | 4 ++-- main/shell-widget.lua | 2 +- main/unit-converter.lua | 8 ++++---- 12 files changed, 34 insertions(+), 34 deletions(-) diff --git a/community/amdroid-nextalarm-app-widget.lua b/community/amdroid-nextalarm-app-widget.lua index 73ae020..7162f63 100644 --- a/community/amdroid-nextalarm-app-widget.lua +++ b/community/amdroid-nextalarm-app-widget.lua @@ -2,7 +2,7 @@ -- description = "AIO wrapper for the Amdroid Next alarm app widget" -- type = "widget" -- author = "Theodor Galanis (t.me/TheodorGalanis)" --- version = "1.10" +-- version = "1.11" -- foldable = "false" -- uses_app = "com.amdroidalarmclock.amdroid" @@ -46,7 +46,7 @@ function on_click(idx) end function on_settings() -ui:show_dialog("Amdroid app Next Alarm widget", "This script wrapper uses Amdroid app's Next alarm widget to display the next scheduled alarm. No settings are required.") +dialogs:show_dialog("Amdroid app Next Alarm widget", "This script wrapper uses Amdroid app's Next alarm widget to display the next scheduled alarm. No settings are required.") end function setup_app_widget() diff --git a/community/birthdays-widget.lua b/community/birthdays-widget.lua index f3d0afe..419f7d2 100644 --- a/community/birthdays-widget.lua +++ b/community/birthdays-widget.lua @@ -3,7 +3,7 @@ -- description = "Shows upcoming birthdays from the contacts" -- type = "widget" -- author = "Andrey Gavrilov" --- version = "1.2" +-- version = "1.3" local prefs = require "prefs" local fmt = require "fmt" @@ -104,7 +104,7 @@ function on_click(idx) end function on_settings() - ui:show_radio_dialog("Number of events", {1,2,3,4,5,6,7,8,9,10}, prefs.count) + dialogs:show_radio_dialog("Number of events", {1,2,3,4,5,6,7,8,9,10}, prefs.count) end function on_dialog_action(idx) diff --git a/community/calllog-ru-root-widget.lua b/community/calllog-ru-root-widget.lua index c6dfc41..bd6e7ed 100644 --- a/community/calllog-ru-root-widget.lua +++ b/community/calllog-ru-root-widget.lua @@ -2,7 +2,7 @@ -- description = "Скрипт показывает историю вызов через прямое чтение базы звонков" -- type = "widget" -- author = "Andrey Gavrilov" --- version = "1.0" +-- version = "1.1" -- lang = "ru" -- root = "true" @@ -77,7 +77,7 @@ end function on_click(idx) if math.ceil(idx/3) > #tab then - ui:show_radio_dialog("Выберите тип вызовов",types,typ) + dialogs:show_radio_dialog("Выберите тип вызовов",types,typ) else local cmd = "am start -a android.intent.action.DIAL -d tel:"..tab[math.ceil(idx/3)].number system:exec(cmd) diff --git a/community/fifteen-widget.lua b/community/fifteen-widget.lua index a7aca2a..22dcabc 100644 --- a/community/fifteen-widget.lua +++ b/community/fifteen-widget.lua @@ -2,7 +2,7 @@ -- description = "Game" -- type = "widget" -- author = "Andrey Gavrilov" --- version = "1.0" +-- version = "1.1" local json = require "json" local folded = "15 puzzle" @@ -96,7 +96,7 @@ end function on_click(idx) if idx == 0 then - ui:show_dialog("Select Action","","Cancel","Reload") + dialogs:show_dialog("Select Action","","Cancel","Reload") return else local tab = tabs_to_tab(tabs_to_desk(tab_to_tabs(json.decode(files:read("fifteen"))))) diff --git a/community/google-search-app-widget.lua b/community/google-search-app-widget.lua index 5b4c534..11f9a07 100644 --- a/community/google-search-app-widget.lua +++ b/community/google-search-app-widget.lua @@ -2,7 +2,7 @@ -- description = "AIO wrapper for the Google search app widget - open widget settings for options" -- type = "widget" -- author = "Theodor Galanis (t.me/TheodorGalanis)" --- version = "2.6" +-- version = "2.7" -- foldable = "false" -- uses_app: "com.google.android.googlequicksearchbox" @@ -53,13 +53,13 @@ elseif idx == indices[4] then w_bridge:click("image_11") elseif idx == indices[5] then w_bridge:click("image_12") - else return + else return end end function on_settings() local tab = {"Left-handed mode with weather", "Left-handed mode, no weather", "Right-handed mode with weather", "Right-handed mode, no weather" } -ui:show_radio_dialog("Select mode", tab, mode) +dialogs:show_radio_dialog("Select mode", tab, mode) end function on_long_click(idx) @@ -70,7 +70,7 @@ ui:show_toast("Google weather") elseif idx == indices[3] then ui:show_toast("Google discover") elseif idx == indices[4] then - ui:show_toast("Google voice search") + ui:show_toast("Google voice search") elseif idx == indices[5] then ui:show_toast("Google Lens") end @@ -86,7 +86,7 @@ end function setup_app_widget() local id = widgets:setup("com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.SearchWidgetProvider") - + if (id ~= nil) then prefs.wid = id else @@ -125,4 +125,4 @@ tab.category = "MAIN" tab.package = "com.google.android.googlequicksearchbox" tab.component = "com.google.android.googlequicksearchbox/com.google.android.apps.search.weather.WeatherExportedActivity" return tab -end \ No newline at end of file +end diff --git a/community/google-translate-widget.lua b/community/google-translate-widget.lua index 52d3112..c48052b 100644 --- a/community/google-translate-widget.lua +++ b/community/google-translate-widget.lua @@ -2,7 +2,7 @@ -- data_source = "https://translate.google.com" -- type = "widget" -- author = "Andrey Gavrilov" --- version = "1.2" +-- version = "1.3" local json = require "json" local uri = "http://translate.googleapis.com/translate_a/single?client=gtx&sl=auto" @@ -13,7 +13,7 @@ function on_resume() end function on_click() - ui:show_edit_dialog("Enter text") + dialogs:show_edit_dialog("Enter text") end function on_dialog_action(text) diff --git a/community/quickactions-widget.lua b/community/quickactions-widget.lua index 7fb35c1..64851df 100644 --- a/community/quickactions-widget.lua +++ b/community/quickactions-widget.lua @@ -4,7 +4,7 @@ -- arguments_help = "Long click button for options, open widget settings for list of buttons" --foldable = "true" -- author = "Theodor Galanis" --- version = "2.5" +-- version = "2.6" md_colors = require "md_colors" @@ -35,7 +35,7 @@ function on_long_click(idx) pos = idx local tab = settings:get() label = get_label(actions[get_checkbox_idx()[idx]]) - if label == nil then + if label == nil then label = names[get_checkbox_idx()[idx]] end ui:show_context_menu({{"angle-left",""},{"ban",""},{"angle-right",""},{icons[get_checkbox_idx()[idx]]:gsub("fa:",""),label}}) @@ -66,13 +66,13 @@ axions = aio:actions() lab = {} for i = 1, #axions do lav = get_label(actions[i]) - if lav == nil then + if lav == nil then table.insert(lab,names[i]) - else + else table.insert(lab, lav) end end - ui:show_checkbox_dialog("Select actions", lab, get_checkbox_idx()) + dialogs:show_checkbox_dialog("Select actions", lab, get_checkbox_idx()) end --utilities-- @@ -140,4 +140,4 @@ axions = aio:actions() return action["label"] end end -end \ No newline at end of file +end diff --git a/community/tvguide-ru-widget.lua b/community/tvguide-ru-widget.lua index f77fbff..2d0b570 100644 --- a/community/tvguide-ru-widget.lua +++ b/community/tvguide-ru-widget.lua @@ -1,7 +1,7 @@ -- name = "ТВ-Программа" -- description = "Программа передач россиийского ТВ" -- type = "widget" --- version = "1.0" +-- version = "1.1" -- lang = "ru" -- author = "Andrey Gavrilov" @@ -23,9 +23,9 @@ end function on_click(idx) if math.ceil(idx/2) > #tab_desc then - ui:show_edit_dialog("Введите название канала","",title) + dialogs:show_edit_dialog("Введите название канала","",title) else - ui:show_dialog(tab_name[math.ceil(idx/2)].."\n"..tab_time[math.ceil(idx/2)],tab_desc[math.ceil(idx/2)],"Перейти к каналу") + dialogs:show_dialog(tab_name[math.ceil(idx/2)].."\n"..tab_time[math.ceil(idx/2)],tab_desc[math.ceil(idx/2)],"Перейти к каналу") link = tab_link[math.ceil(idx/2)] end end diff --git a/community/widgets-on-off.lua b/community/widgets-on-off.lua index 2d8e8bf..23adabc 100644 --- a/community/widgets-on-off.lua +++ b/community/widgets-on-off.lua @@ -2,7 +2,7 @@ -- description = "Turns screen widgets on and off when buttons are pressed" -- type = "widget" -- author = "Andrey Gavrilov" --- version = "3.0" +-- version = "3.1" prefs = require "prefs" @@ -56,7 +56,7 @@ function on_dialog_action(data) end function on_settings() - ui:show_checkbox_dialog("Select widgets", widgets.label, indexes) + dialogs:show_checkbox_dialog("Select widgets", widgets.label, indexes) end function get_indexes(tab1,tab2) diff --git a/main/calendar.lua b/main/calendar.lua index cbde23d..9533a0c 100644 --- a/main/calendar.lua +++ b/main/calendar.lua @@ -32,7 +32,7 @@ end function on_settings() dialog_id = "settings" - ui:show_checkbox_dialog("Check calendars", get_all_cals()[3],cal_id_to_id(settings:get())) + dialogs:show_checkbox_dialog("Check calendars", get_all_cals()[3],cal_id_to_id(settings:get())) end function on_click(i) @@ -51,7 +51,7 @@ function on_click(i) on_resume() elseif i > 1 and i < 8 then dialog_id = "date" - ui:show_edit_dialog("Enter month and year", "Format - 12.2020. Empty value - current month", string.format("%02d.%04d", month, year)) + dialogs:show_edit_dialog("Enter month and year", "Format - 12.2020. Empty value - current month", string.format("%02d.%04d", month, year)) return elseif (i-1)%8 ~= 0 and tab[i] ~= " " then day = tab[i]:match(">(%d+)<"):gsub("^0","") diff --git a/main/shell-widget.lua b/main/shell-widget.lua index 0d10ae1..8f9f52a 100644 --- a/main/shell-widget.lua +++ b/main/shell-widget.lua @@ -20,7 +20,7 @@ function redraw() end function on_click(idx) - ui:show_edit_dialog("Enter command") + dialogs:show_edit_dialog("Enter command") end function on_dialog_action(text) diff --git a/main/unit-converter.lua b/main/unit-converter.lua index 20d25f2..17fb70d 100644 --- a/main/unit-converter.lua +++ b/main/unit-converter.lua @@ -37,10 +37,10 @@ end function on_click(idx) if idx == 1 then dialog_id ="amount" - ui:show_edit_dialog("Enter amount", "", amount) + dialogs:show_edit_dialog("Enter amount", "", amount) elseif idx == 2 then dialog_id = "unit_from" - ui:show_radio_dialog("Select unit",get_radio_tab(unit),get_radio_idx(unit_from)) + dialogs:show_radio_dialog("Select unit",get_radio_tab(unit),get_radio_idx(unit_from)) elseif idx == 3 then local unit_tmp = unit_from unit_from = unit_to @@ -50,10 +50,10 @@ function on_click(idx) system:copy_to_clipboard(sum) elseif idx == 5 then dialog_id = "unit_to" - ui:show_radio_dialog("Select unit",get_radio_tab(unit),get_radio_idx(unit_to)) + dialogs:show_radio_dialog("Select unit",get_radio_tab(unit),get_radio_idx(unit_to)) elseif idx == 6 then dialog_id = "unit" - ui:show_radio_dialog("Select converter",get_radio_tab(""),get_radio_idx(unit)) + dialogs:show_radio_dialog("Select converter",get_radio_tab(""),get_radio_idx(unit)) end end -- 2.43.0 From 934cd29dff3faf6cf2da8be80f6e9367efa9587e Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 5 Jun 2025 17:07:16 +0800 Subject: [PATCH 182/204] Update scripts.zip --- scripts.md5 | 2 +- scripts.zip | Bin 18528 -> 18536 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts.md5 b/scripts.md5 index 3e658dc..51ce2c3 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -75d35325b380ccd55a2f8b34187a5ab1 +230980f1047f9b17234b4fa5ec7e0c7d diff --git a/scripts.zip b/scripts.zip index d3b8d38b76e5dd3e52cc42c6632ffa6077f3c54f..8fc8d61838b3b28ffdaea5a45dfd78cdcf83f503 100644 GIT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M@~vy=>MeX9oJ1ym;7R5zl)q=CEJKWqYoZrMlD_&+QrB1cIJya z3mn_Yk`hQZe}S6ir(ISmp$h3utZSRL*9!wiv_tm6L zgU2y`h3B=AqM*{I9_$n(m2Rs6k+=53^zFhoIea=$ggE+hF9lvuc;+cExJ3^wYWZJg z)Ey+P`m)!nml#;cr#=G7BW;d;Q3o~kguo#`Nv{y3frGp>)W#3*jR;+A-X_vrR*Bs2 z8@HHuK^BllFjQRci*Xbj5%yJHQ|5nRGm5Ug4?mSEVt}pg6L{QulKaeA$gD;`507gi zZ&Ek*crkA>{Px?3qscs!L7Kj5u%PA~hjM6IX+XODmyRY75R(Z zwh3s^b)2&0?gkV{{^EJwhO>Uy)0D%TC^w5_g$oN#7s9w@I|#*V<<)c~_kf|BC0({# z5j<^&%B zL^zLJi~3d!F6txoRo2gR75r{Y1_^ljI?RhZh<*HmtS>o0Co+Wop0s~cY2Fazr%0Oz znZCNB4f%tHxsZu_3lhtW6KN>_1BvqCvSONQ$@a$`KSlo;O2;I(;IBRoZgzybTL*ezjmiKr?B?y9Z1|t71 zJqXKrzn%X-kNkIa#u0~iIY3w-!8&tbVMMv+ONkLCvp7s-sy`x|F#(7$CR#A2_*huM z-tiw$NmXTJ`o# Date: Fri, 6 Jun 2025 07:40:54 +0800 Subject: [PATCH 183/204] Replace deprecated functions in currency-ru-wdiget.lua --- ru/currency-ru-widget.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ru/currency-ru-widget.lua b/ru/currency-ru-widget.lua index e837d96..740c661 100644 --- a/ru/currency-ru-widget.lua +++ b/ru/currency-ru-widget.lua @@ -25,7 +25,7 @@ function on_long_click() if history == "" then return end - ui:show_dialog("История курсов ЦБ\n"..nominal.." "..cur.." / "..base_cur,history) + dialogs:show_dialog("История курсов ЦБ\n"..nominal.." "..cur.." / "..base_cur,history) end function on_settings() @@ -38,7 +38,7 @@ function on_settings() idx = i end end - ui:show_radio_dialog("Выберите валюту",names,idx) + dialogs:show_radio_dialog("Выберите валюту",names,idx) end function on_dialog_action(data) @@ -64,7 +64,7 @@ function on_network_result_today(result,error) end today = today..v.Nominal:value().." "..v.CharCode:value().." = "..v.Value:value():replace(",",".").." "..base_cur end - ui:show_dialog("Курсы валют ЦБ\n"..date_today,today) + dialogs:show_dialog("Курсы валют ЦБ\n"..date_today,today) end function on_network_result_history(result,error) -- 2.43.0 From bfd42cb2e7ece997729f1aa435616047740c69f1 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 6 Jun 2025 07:42:43 +0800 Subject: [PATCH 184/204] Move some widgets from main to community --- {ru => community}/isdayoff-ru-widget.lua | 0 {main => community}/shell-widget.lua | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {ru => community}/isdayoff-ru-widget.lua (100%) rename {main => community}/shell-widget.lua (100%) diff --git a/ru/isdayoff-ru-widget.lua b/community/isdayoff-ru-widget.lua similarity index 100% rename from ru/isdayoff-ru-widget.lua rename to community/isdayoff-ru-widget.lua diff --git a/main/shell-widget.lua b/community/shell-widget.lua similarity index 100% rename from main/shell-widget.lua rename to community/shell-widget.lua -- 2.43.0 From bec53749db4c499b51e5dfa33ab3758b245a1930 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 6 Jun 2025 07:43:04 +0800 Subject: [PATCH 185/204] Update scripts.zip --- scripts.index | 2 -- scripts.md5 | 2 +- scripts.zip | Bin 18536 -> 17531 bytes 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts.index b/scripts.index index 18008be..91c82d4 100644 --- a/scripts.index +++ b/scripts.index @@ -6,7 +6,6 @@ dice-widget.lua facts-widget.lua inspiration-quotes-widget.lua public-ip-widget.lua -shell-widget.lua sunrise-sunset-widget.lua sys-info-widget.lua tasks-menu.lua @@ -15,5 +14,4 @@ wikipedia-widget.lua year_progress-widget.lua currency-ru-widget.lua holydays-ru-widget.lua -isdayoff-ru-widget.lua quotes-ru-widget.lua diff --git a/scripts.md5 b/scripts.md5 index 51ce2c3..486dd72 100644 --- a/scripts.md5 +++ b/scripts.md5 @@ -1 +1 @@ -230980f1047f9b17234b4fa5ec7e0c7d +7a167ae5d16734c40c2b0237e00b558d diff --git a/scripts.zip b/scripts.zip index 8fc8d61838b3b28ffdaea5a45dfd78cdcf83f503..dad6b52dd7e89391549aabec64901a89a164e191 100644 GIT binary patch delta 3201 zcmV-{41V+IkOBLM0kBjSlhi~Kv+@^v7ZU|N##&GSNm?-s000Fr000&M9Fq}88Gi`? z1KKJ=Xxb`5XmxlC009K(0{{R7=mP)%y;^;5+r}CH+xip)hYWHm>(#Ps!*b`?Nu2nl znH9H9QbRb47l}1RYDdzJQWVI`HVjDDHeCl4#fr7tu=TIaapJ^rV)rXh-)PTsq(sV; zc$ACHi7oQ(cz3_&`8_Z9P!ki9PJfzIDoe8SZRc_4LFZxTiR2tO`_7xr=bcBA^H1lg zoS2x96l&I(+Okwb=cB)Jj+__HOXm;=opv5Mr_Qs^19T_w9r)r?)Lj>>oqQAL$4BzuzzN9JR!jkK&mogQ4{W|uJjMAX=-i98;IhWh0)1Df^wB; zWhu80nNpPai4t3 z8}9<0)YPt|>XOTXmearjGk;PvaQjys+*KqNj^_%H@yy@v%ByF zO^%QEhJuiH@5sNpwtpmVp_Dxy^+}o!<2+J(ZC#NM6g?w~YWNEHs`JEo29}Bnc;p-g zjI{GuPPyBI`3FeWouW#3LlTX%#|*r|4Nv5RwD|c7aV@Y<-gj^VTj^_+_o|Bx!m5jg z(vxoY8P_5QJmv{J;Y${q#m1*oYtLXiRYpx)v#Q*blI~54GJj^U^D@w#V>~hDb>hUX zm+)F(f3(_d=7<(;W&(~S=l~>RL+FX4T>O+XbZiWCr_Osy8yg$z&5562b#vQn9#$Pg z?4e#Dv1_PZNqYvnn?@Z3Re&93w+mPAwa+rz(nyUa!4swAwA`JcYvu`e;lZ9{Xx!pH z#1~PD{}t=cbAKrVG}z~;eWle5jRzH?8ngVm-{*j;iH0sip1W)4mOH%sk&G@4FViNi z8M;DPyK2#U7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4a^``dz$Vk znt>op*?reNenVB#Z>VDX4OQMD?k-UQC=@I>3=_mCgf7S<8uUxD4DVgAypWtp+-+TW zI|(W473&gdFkWyj$`T+J+lZ$1kuRwq&=Cl8R;`|Ti|+(#>Wy)dlcl9OmxpQ!Cvob| ziRwIUht}d>I|=XF?cWITdir2VqBcEh^bW(P8d;G8`|8dHJEiO;=lKD_Rkwm)?rIXD zm!GM>q6_VTVNIiDz7aLh!sH7yI+!!{aX0q)DyY{L z-<6ai68PV_Zq-gi!!@Tei~8sosB(k?ChG>SfESdnha)4k6^f|mnGbJ zjdRsQ95-TRRh%#aj;m?<0?Orcl|~h`4NEIhgFB|yNyerQ+b%|HcZs6~oa%A&{@}X` zx}EzZ^zy|K5qkxWL@?OCo4OQJn?C0sJEAi)BqPUM*XC$yRn8`d|6khW0Q{-ne*#n_ z8n6NWANB?RW?zhyCKMy7PL8?9Mo<55$qYNjO~ZlK1@c=N6$112M+IPj>e85B8eAaq z8yJYD1*nb}6QGFziHc!{HSd8q#W8$Zs(-w=|A+PdB;?<&ZW0)@)(woh7SDf{_Goc| z7L_myTI#p{cdGua;Z+6vcg8Sk+QOJ6b$Sd$n+r6phLP8nqh|&%1D;a=0F4@d4*oAt CT#*d` -- 2.43.0 From a4d7b80950ca0fcbc10f5d9d41b11900695bd28e Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 12 Jun 2025 05:48:33 +0800 Subject: [PATCH 186/204] Update README --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3089938..0297a02 100644 --- a/README.md +++ b/README.md @@ -194,11 +194,11 @@ _Note: AIO only supports icons up to Fontawesome 6.3.0._ _Available only in widget scripts._ -* `ui:show_dialog(title, text, [button1_text], [button2_text])` - show dialog, the first argument is the title, the second is the text, button1\_text is the name of the first button, button2\_text is the name of the second button; -* `ui:show_edit_dialog(title, [text], [default_value])` - show the dialog with the input field: title - title, text - signature, default\_value - standard value of the input field; -* `ui:show_radio_dialog (title, lines, [index])` - show a dialog with a choice: title - title, lines - table of lines, index - index of the default value; -* `ui:show_checkbox_dialog(title, lines, [table])` - show dialog with selection of several elements: title - title, lines - table of lines, table - table default values; -* `ui:show_list_dialog(prefs)` - shows dialog with list of data. +* `dialogs:show_dialog(title, text, [button1_text], [button2_text])` - show dialog, the first argument is the title, the second is the text, button1\_text is the name of the first button, button2\_text is the name of the second button; +* `dialogs:show_edit_dialog(title, [text], [default_value])` - show the dialog with the input field: title - title, text - signature, default\_value - standard value of the input field; +* `dialogs:show_radio_dialog (title, lines, [index])` - show a dialog with a choice: title - title, lines - table of lines, index - index of the default value; +* `dialogs:show_checkbox_dialog(title, lines, [table])` - show dialog with selection of several elements: title - title, lines - table of lines, table - table default values; +* `dialogs:show_list_dialog(prefs)` - shows dialog with list of data. Dialog button clicks should be handled in the `on_dialog_action(number)` callback, where 1 is the first button, 2 is the second button, and -1 is nothing (dialog just closed). `ui:show_radio_dialog()` returns the index of the selected item or -1 in case the cancel button was pressed. `ui:show_checkbox_dialog()` returns the table of indexes or -1. `ui:show_edit_dialog()` returns text or -1. @@ -218,7 +218,7 @@ List dialog accepts table as argument: _Avaialble from: 4.4.1_ -* `ui:show_rich_editor(prefs)` - show complex editor dialog with undo support, lists, time, colors support. It can be used to create notes and tasks style widgets. +* `dialogs:show_rich_editor(prefs)` - show complex editor dialog with undo support, lists, time, colors support. It can be used to create notes and tasks style widgets. Dialog accepts table as argument: -- 2.43.0 From 7792fec8ac3cd7bc6bdf9be22d87a52cdc46be21 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 12 Jun 2025 06:06:52 +0800 Subject: [PATCH 187/204] Update Profile Switcher script --- community/profiles-restore-save-widget.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/community/profiles-restore-save-widget.lua b/community/profiles-restore-save-widget.lua index f4c0c33..578fb22 100644 --- a/community/profiles-restore-save-widget.lua +++ b/community/profiles-restore-save-widget.lua @@ -1,5 +1,5 @@ -- name = "Profile Switcher" --- version = "1.0" +-- version = "1.1" -- description = "Tap: restore profile / Long-press: save to profile" -- type = "widget" -- author = "Marcus Johansson" @@ -22,7 +22,7 @@ function on_long_click(idx) profile = profs[idx] title = 'Save to "'..profile..'" ?' text = 'Do you want to save the current screen state to the "'..profile..'" profile ?' - ui:show_dialog(title, text, "Yes", "Cancel") + dialogs:show_dialog(title, text, "Yes", "Cancel") end function on_dialog_action(value) -- 2.43.0 From 4b377577e56e82e35e272060db14462807462152 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 24 Jun 2025 12:04:51 +0800 Subject: [PATCH 188/204] Add thirukkural widget --- community/thirukkural-widget.lua | 80 ++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 community/thirukkural-widget.lua diff --git a/community/thirukkural-widget.lua b/community/thirukkural-widget.lua new file mode 100644 index 0000000..519cbd5 --- /dev/null +++ b/community/thirukkural-widget.lua @@ -0,0 +1,80 @@ +-- name = "Thirukkural" +-- description = "Thirukkural Widget that refreshes a verse form the Tamil Book Thirukkural. Single click will open the diaglog with multiple translations in English and Tamili. Long press will retrive a new verse. This uses the API from getthirukural" +-- data_source = "https://getthirukural.appspot.com/" +-- type = "widget" +-- author = "Abdul MJ (mjabdulm@gmail.com)" +-- version = "1.0" +-- foldable = "false" + +local json = require "json" +local kural_data = nil -- Store the kural translation data + +function on_alarm() + -- Fetch random kural with English translation + -- http:get("https://api.alquran.cloud/v1/ayah/random/en.sahih") + http:get("https://getthirukural.appspot.com/api/3.0/kural/rnd?appid=bzh3rnqagllov") +end + +function on_network_result(result) + local response = json.decode(result) + + if response then + -- Store kural data including athigaram name, kural number + kural_data = { + number = response.number, + line1 = response.line1, + line2 = response.line2, + paal = response.paal, + athigaram = response.athigaram, + iyal = response.iyal, + urai1Author = response.urai1Author, + urai2Author = response.urai2Author, + urai3Author = response.urai3Author, + urai1 = response.urai1, + urai2 = response.urai2, + urai3 = response.urai3, + en = response.en + } + + display_kural() + else + ui:show_message("Error loading kural data.") + end +end + +function display_kural() + if kural_data then + local display_lines = { + -- kural_data.number .. " : " .. kural_data.line1 .. "
       " .. kural_data.line2 + -- kural_data.line1 .. "
" .. kural_data.line2 .. " - " .. kural_data.number .. ":".. kural_data.athigaram .. ":" .. kural_data.paal .. "" + kural_data.line1 .. "
" .. kural_data.line2 .. " -" .. kural_data.number .. "" + -- kural_data.line1 .. "
" .. kural_data.line2 .. [[- ]] .. kural_data.number .. ":" .. kural_data.athigaram .. "" + } + + -- ui:show_lines(display_lines display_titles) + ui:show_lines(display_lines) + end +end + +function on_click() + if kural_data then + -- Prepare text to copy to clipboard with English translation only + local title = "Thirukkural:" .. kural_data.number + + local text = kural_data.number .. ":" .. kural_data.paal .. ":" .. kural_data.iyal .. ":" .. kural_data.athigaram .. "

Kural
" .. kural_data.line1 .. "
" .. kural_data.line2 .. "

English:
" .. kural_data.en .. "" .. kural_data.urai1Author .. "
" .. kural_data.urai1 .. "" .. kural_data.urai2Author .. "
" .. kural_data.urai2 .. "" .. kural_data.urai3Author .. "
" .. kural_data.urai3 + + -- system:to_clipboard(clipboard_text) + dialogs:show_dialog(title,text) + display_kural() + -- ui:show_lines(clipboard_text) + else + ui:show_message("No kural available to copy.") + end +end + +function on_long_click() + -- Fetch random kural on long-click + http:get("https://getthirukural.appspot.com/api/3.0/kural/rnd?appid=bzh3rnqagllov") +end + + -- 2.43.0 From e744b0dc4600e6de89c048bd8f24bde93a347324 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 26 Jun 2025 12:10:25 +0800 Subject: [PATCH 189/204] Fix typo --- README_RICH_UI.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_RICH_UI.md b/README_RICH_UI.md index 00b267a..bbb86f3 100644 --- a/README_RICH_UI.md +++ b/README_RICH_UI.md @@ -88,7 +88,7 @@ This is all you need to know about the new API. Below is an example demonstratin {"text", "", {size = 17, color = "", gravity = "left"}}, {"button", "", {color = "", gravity = "left", expand = "false"}}, {"icon", "", {size = 17, color = "", gravity = "left"}}, -{"progress" "", {progress = 0, color = "", gravity = "left"}}, +{"progress", "", {progress = 0, color = "", gravity = "left"}}, {"new_line", 0}, {"spacer", 0}, ``` -- 2.43.0 From ff61bad9bfcf6c5b0cc4f7ee52ed4e1ef6c7f759 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 26 Jun 2025 13:39:04 +0800 Subject: [PATCH 190/204] Fix typo --- README_RICH_UI.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_RICH_UI.md b/README_RICH_UI.md index bbb86f3..f920477 100644 --- a/README_RICH_UI.md +++ b/README_RICH_UI.md @@ -88,7 +88,7 @@ This is all you need to know about the new API. Below is an example demonstratin {"text", "", {size = 17, color = "", gravity = "left"}}, {"button", "", {color = "", gravity = "left", expand = "false"}}, {"icon", "", {size = 17, color = "", gravity = "left"}}, -{"progress", "", {progress = 0, color = "", gravity = "left"}}, +{"progress", "", {progress = 0, color = ""}}, {"new_line", 0}, {"spacer", 0}, ``` -- 2.43.0 From c42280333bd507882fcf56ded19a0745a8d7a3f5 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 27 Jun 2025 08:21:14 +0800 Subject: [PATCH 191/204] Update samples --- samples/rich-gui-sample.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/samples/rich-gui-sample.lua b/samples/rich-gui-sample.lua index 6c1e520..be1c543 100644 --- a/samples/rich-gui-sample.lua +++ b/samples/rich-gui-sample.lua @@ -24,9 +24,19 @@ function on_resume() {"spacer", 2}, {"button", "Cancel", {color = "#ff0000", gravity = "right"}}, {"new_line", 2}, + {"button", "Button"}, + {"spacer", 2}, + {"text", "Text", {gravity = "center_v"}}, + {"new_line", 2}, {"progress", "Progress #1", {progress = 70}}, {"progress", "Progress #2", {progress = 30, color = "#0000ff"}}, {"new_line", 2}, + {"progress", "Progress #3", {progress = 100, gravity = "center_v"}}, + {"spacer", 2}, + {"text", "Text", {gravity = "center_v|anchor_prev"}}, + {"spacer", 2}, + {"button", "Button"}, + {"new_line", 2}, {"button", "Center button", {gravity = "center_h"}}, {"new_line", 2}, {"button", "Whole width button", {expand = true}}, -- 2.43.0 From 424eaca556460c12773b4af07e2409eb81721c15 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 29 Jun 2025 07:16:41 +0800 Subject: [PATCH 192/204] Add Recent apps widget --- community/recent-apps.lua | 120 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 community/recent-apps.lua diff --git a/community/recent-apps.lua b/community/recent-apps.lua new file mode 100644 index 0000000..1a0b5bd --- /dev/null +++ b/community/recent-apps.lua @@ -0,0 +1,120 @@ +-- name = "Recent Apps" +-- description = "Gets the apps in the recent apps (app overview) screen. Tap to open the app or long press to remove it.\nREQUIRES ROOT and Android 11 or higher." +-- type = "widget" +-- author = "Abi" +-- version = "3.3" +-- foldable = "false" + +local entries = {} + +function on_resume() + system:su('dumpsys activity recents') +end + +function on_shell_result(raw) + local start = raw:find("Visible recent tasks") + if not start then + ui:show_text("No recent apps") + return + end + local trimmed = raw:sub(start) + + local blocks = {} + local pat = "%* RecentTaskInfo #%d+:" + local pos = 1 + while true do + local s,e = trimmed:find(pat, pos) + if not s then break end + local ns,_ = trimmed:find(pat, e+1) + if ns then + blocks[#blocks+1] = trimmed:sub(s, ns-1) + pos = ns + else + blocks[#blocks+1] = trimmed:sub(s) + break + end + end + + entries = {} + for _, block in ipairs(blocks) do + local id = block:match("id=(%d+)") + local has = block:match("hasTask=(%a+)") + local last = block:match("lastActiveTime=(%d+)") + local full = block:match("cmp=([%w%.]+/[%w%._]+)") + local pkg = full and full:match("^([^/]+)") + + if id and has and last and pkg then + entries[#entries+1] = { + id = tonumber(id), + hasTask = (has == "true"), + lastActiveTime = tonumber(last), + packageName = pkg, + appName = get_name_or_color(pkg, "name"), + appColor = get_name_or_color(pkg, "color"), + } + end + end + + if #entries == 0 then + ui:show_toast("No recent apps parsed") + return + end + + do + local names, colors = {}, {} + for i, e in ipairs(entries) do + names[i] = e.appName + colors[i] = e.appColor + end + ui:show_buttons(names, colors) + end +end + +function on_click(idx) + local pkg = entries[idx] and entries[idx].packageName + if pkg then + apps:launch(pkg) + else + ui:show_toast("No package at index "..tostring(idx)) + end +end + +function on_long_click(idx) + local e = entries[idx] + if not e then + ui:show_toast("No app at index "..tostring(idx)) + return + end + + system:su("am stack remove " .. entries[idx].id) + system:su('dumpsys activity recents') +end + +function to_hex_rgb(argb) + if argb < 0 then argb = 4294967296 + argb end + local r = math.floor((argb / 65536) % 256) + local g = math.floor((argb / 256) % 256) + local b = math.floor(argb % 256) + return string.format("#%02X%02X%02X", r, g, b) +end + +function get_name_or_color(pkg, nameorcolor) + local info = apps:app(pkg) + if not info then + if nameorcolor == "name" then + return "???" + elseif nameorcolor == "color" then + return "#FFFFFF" + else + return nil + end + end + + if nameorcolor == "name" then + return info.name or "???" + elseif nameorcolor == "color" then + return to_hex_rgb(info.color or 0xFFFFFF) + else + return nil + end +end -- 2.43.0 From 7fb84c38e79903949fc74a7ba392be85c669726b Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 5 Jul 2025 07:38:55 +0800 Subject: [PATCH 193/204] Add habits widget --- community/habits-widget.lua | 217 ++++++++++++++++++++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100644 community/habits-widget.lua diff --git a/community/habits-widget.lua b/community/habits-widget.lua new file mode 100644 index 0000000..a50b40b --- /dev/null +++ b/community/habits-widget.lua @@ -0,0 +1,217 @@ +-- name = "Habit tracker" +-- description = "Daily habit tracker with JSON storage" +-- type = "widget" +-- author = "Sergey Mironov" +-- version = "1.0" + +local json = require("json") +local md = require("md_colors") + +local buttons = {} +local filename = "button_data.json" +local dialog_state = nil -- Track current dialog state + +-- Get current date in YYYY-MM-DD format +local function get_current_date() + return os.date("%Y-%m-%d") +end + +-- Load button data from JSON file +local function load_data() + local content = files:read(filename) + if content then + local success, data = pcall(json.decode, content) + if success and data then + buttons = data + else + buttons = {} + end + else + buttons = {} + end +end + +-- Save button data to JSON file +local function save_data() + local content = json.encode(buttons) + files:write(filename, content) +end + +-- Display all buttons +local function display_buttons() + local names = {} + local colors = {} + local current_date = get_current_date() + + -- Add the "+" button at the beginning + table.insert(names, "fa:plus") + table.insert(colors, aio:colors().button) -- Gray color for add button + + -- Add existing buttons + for i, button in ipairs(buttons) do + table.insert(names, button.title) + + -- Check if button was clicked today + if button.last_clicked == current_date then + table.insert(colors, md.green_600) -- Green if clicked today + else + table.insert(colors, button.color) -- Original color + end + end + + ui:show_buttons(names, colors) +end + +-- Handle button clicks +function on_click(index) + local current_date = get_current_date() + + -- Check if it's the "+" button (first button) + if index == 1 then + -- Show add dialog - ask for title first + dialog_state = {action = "add_title"} + dialogs:show_edit_dialog("Add New Button", "Enter button title:", "") + return + end + + -- Handle existing button click (adjust index for "+" button) + local button_index = index - 1 + local button = buttons[button_index] + if button.last_clicked == current_date then + -- Already clicked today, reset + button.last_clicked = "" + ui:show_toast("Unmarked: " .. button.title) + else + -- Not clicked today, mark as clicked + button.last_clicked = current_date + ui:show_toast("Marked: " .. button.title) + end + + save_data() + display_buttons() +end + +-- Handle long clicks for editing +function on_long_click(index) + -- Don't allow long-click on "+" button (first button) + if index == 1 then + return + end + + -- Show edit options (adjust index for "+" button) + local button_index = index - 1 + dialog_state = {action = "edit_options", index = button_index} + local button = buttons[button_index] + dialogs:show_dialog("Edit Button: " .. button.title, "Choose action:", "Edit", "Delete") +end + +-- Handle dialog results +function on_dialog_action(value) + if value == -1 then + -- Cancel pressed + dialog_state = nil + return + end + + if not dialog_state then + return + end + + if dialog_state.action == "add_title" then + if type(value) == "string" and value:trim() ~= "" then + -- Got title, now ask for color + dialog_state = {action = "add_color", title = value} + dialogs:show_edit_dialog("Add New Button\nTitle: " .. value, "Enter color (e.g., #FF0000):", "#FF0000") + else + ui:show_toast("Invalid title") + dialog_state = nil + end + + elseif dialog_state.action == "add_color" then + if type(value) == "string" and value:match("^#%x%x%x%x%x%x$") then + -- Valid color, create button + local new_button = { + title = dialog_state.title, + color = value, + last_clicked = "" + } + table.insert(buttons, new_button) + save_data() + display_buttons() + ui:show_toast("Added: " .. dialog_state.title) + else + ui:show_toast("Invalid color format. Use #RRGGBB") + end + dialog_state = nil + + elseif dialog_state.action == "edit_options" then + if value == 1 then + -- Edit button - ask for new title + local button = buttons[dialog_state.index] + dialog_state = {action = "edit_title", index = dialog_state.index} + dialogs:show_edit_dialog("Edit Button", "Enter new title:", button.title) + elseif value == 2 then + -- Delete button + local button = buttons[dialog_state.index] + table.remove(buttons, dialog_state.index) + save_data() + display_buttons() + ui:show_toast("Deleted: " .. button.title) + dialog_state = nil + end + + elseif dialog_state.action == "edit_title" then + if type(value) == "string" and value:trim() ~= "" then + -- Got new title, now ask for color + local button = buttons[dialog_state.index] + dialog_state = {action = "edit_color", index = dialog_state.index, title = value} + dialogs:show_edit_dialog("Edit Button\nTitle: " .. value, "Enter new color:", button.color) + else + ui:show_toast("Invalid title") + dialog_state = nil + end + + elseif dialog_state.action == "edit_color" then + if type(value) == "string" and value:match("^#%x%x%x%x%x%x$") then + -- Valid color, update button + local button = buttons[dialog_state.index] + button.title = dialog_state.title + button.color = value + save_data() + display_buttons() + ui:show_toast("Updated: " .. button.title) + else + ui:show_toast("Invalid color format. Use #RRGGBB") + end + dialog_state = nil + end +end + +-- Initialize widget +function on_resume() + load_data() + + -- Add some sample data if empty + if #buttons == 0 then + buttons = { + { + title = "Exercise", + color = md.pink_600, + last_clicked = "" + }, + { + title = "Read", + color = md.cyan_600, + last_clicked = "" + }, + { + title = "Water", + color = md.light_blue_600, + last_clicked = "" + } + } + save_data() + end + + display_buttons() +end -- 2.43.0 From a897f1ed0dbb195a1af9d6b58f7095f98f832298 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 5 Jul 2025 07:43:25 +0800 Subject: [PATCH 194/204] Cleanup --- community/{recent-apps.lua => recent-apps-widget.lua} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename community/{recent-apps.lua => recent-apps-widget.lua} (100%) diff --git a/community/recent-apps.lua b/community/recent-apps-widget.lua similarity index 100% rename from community/recent-apps.lua rename to community/recent-apps-widget.lua -- 2.43.0 From c9caad241020ae02155f7a1af6ce24e4120a5840 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 6 Jul 2025 07:38:55 +0800 Subject: [PATCH 195/204] Add more tests --- samples/back_button_test.lua | 21 +++++++++++++++++++++ samples/on_resume_test.lua | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 samples/back_button_test.lua diff --git a/samples/back_button_test.lua b/samples/back_button_test.lua new file mode 100644 index 0000000..08fdc0c --- /dev/null +++ b/samples/back_button_test.lua @@ -0,0 +1,21 @@ +local names = { "Test", "Blah", "Works?", "Or not?" } +local colors = { "#FF5733", "#33FF57", "#3357FF", "#FF33A1" } + +function on_resume() + ui:show_toast("Called!") + shuffle(names) + shuffle(colors) + ui:show_buttons(names, colors) +end + +function on_click(idx) + apps:launch("org.telegram.messenger") +end + +function shuffle(t) + for i = #t, 2, -1 do + local j = math.random(1, i) + t[i], t[j] = t[j], t[i] + end +end + diff --git a/samples/on_resume_test.lua b/samples/on_resume_test.lua index f3361af..090a1be 100644 --- a/samples/on_resume_test.lua +++ b/samples/on_resume_test.lua @@ -2,5 +2,5 @@ local i = 0 function on_resume() i = i + 1 - ui:show_toast("on_resume called: "..i) + ui:show_text("on_resume called: "..i) end -- 2.43.0 From 74f0b60e977136f19d43982e14598cca8bdb14dc Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 7 Jul 2025 07:56:48 +0800 Subject: [PATCH 196/204] Fix readme typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0297a02..5afb2c1 100644 --- a/README.md +++ b/README.md @@ -786,7 +786,7 @@ There are two modules to solve this problem: `morph` and `anim`. The first is us * `morph:run_with_delay(delay, function)` - populates specified Lua function with delay `delay`; * `morph:cancel(idx)` - cancels a previously run change if it is not yet complete (e.g., delay or animation is not over). * `anim:blink(idx)` - blinks UI element with index `idx`; -* `anim:move(x, y, [delay])` - moves element sideways by specified number of DP and returns back after delay; +* `anim:move(idx, x, y, [delay])` - moves element sideways by specified number of DP and returns back after delay; * `anim:heartbeat(idx)` - animation of heartbeat; * `anim:shake(idx)` - shake animation; * `anim:cancel(idx)` - cancel the running animation. -- 2.43.0 From 4d3ee33c01d178b33890374ede3271f49e028689 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 13 Jul 2025 07:24:06 +0800 Subject: [PATCH 197/204] Add aio:colors() table description --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 5afb2c1..581082d 100644 --- a/README.md +++ b/README.md @@ -416,6 +416,22 @@ Format of table elements returned by `aio:actions()`: `args` - action arguments if any. ``` +Format of table elements returned by `aio:colors()`: + +``` +`primary_text` – base text color; +`secondary_text` – color for secondary text (e.g., sender name, time, etc.); +`button` – button background color; +`button_text` – text color inside buttons; +`progress` – general progress bar color; +`progress_good` – color for positive progress states (e.g., full battery or charging); +`progress_bad` – color for negative progress states (e.g., battery level below 15%); +`enabled_icon` – color for enabled icons (see the Control Panel widget); +`disabled_icon` – color for disabled icons (see the Control Panel widget); +`accent` – accent color; +`badge` – badge color. +``` + To accept a value sent by the `send_message` function, the receiving script must implement a callback `on_message(value)`. The script can track screen operations such as adding, removing or moving a widget with the `on_widget_action()` callback. For example: -- 2.43.0 From 51f0eac6eecbb2f986b8859c7e6a9f204854b57a Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 15 Jul 2025 21:03:39 +0800 Subject: [PATCH 198/204] Update google search app widget --- community/google-search-app-widget.lua | 146 ++++++++++++------------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/community/google-search-app-widget.lua b/community/google-search-app-widget.lua index 11f9a07..8f85ab2 100644 --- a/community/google-search-app-widget.lua +++ b/community/google-search-app-widget.lua @@ -2,9 +2,9 @@ -- description = "AIO wrapper for the Google search app widget - open widget settings for options" -- type = "widget" -- author = "Theodor Galanis (t.me/TheodorGalanis)" --- version = "2.7" +-- version = "2.8" -- foldable = "false" --- uses_app: "com.google.android.googlequicksearchbox" +-- uses_app = "com.google.android.googlequicksearchbox" local prefs = require "prefs" @@ -16,78 +16,78 @@ function on_alarm() setup_app_widget() end if not prefs.mode then - prefs.mode = 1 + prefs.mode = 1 end - mode = prefs.mode - indices = set_indices() - widgets:request_updates(prefs.wid) + mode = prefs.mode + indices = set_indices() + widgets:request_updates(prefs.wid, "4x1") end function on_app_widget_updated(bridge) w_bridge = bridge local tab = { -{"button", "fa:magnifying-glass", {expand = true}}, -{"spacer", 2}, -{"button", "fa:sun-cloud"}, -{"spacer", 2}, -{"button", "fa:asterisk"}, -{"spacer", 2}, -{"button", "fa:microphone"}, -{"spacer", 2}, -{"button", "fa:camera"} -} + {"button", "fa:magnifying-glass", {expand = true}}, + {"spacer", 2}, + {"button", "fa:sun-cloud"}, + {"spacer", 2}, + {"button", "fa:asterisk"}, + {"spacer", 2}, + {"button", "fa:microphone"}, + {"spacer", 2}, + {"button", "fa:camera"} + } -tab = set_gui(tab) -my_gui = gui(tab) -my_gui.render() + tab = set_gui(tab) + my_gui = gui(tab) + my_gui.render() end function on_click(idx) -if idx == indices[1] then - w_bridge:click("image_4") -elseif idx == indices[2] then - intent:start_activity(open_weather()) -elseif idx == indices[3] then - w_bridge:click("image_7") -elseif idx == indices[4] then - w_bridge:click("image_11") -elseif idx == indices[5] then - w_bridge:click("image_12") - else return -end + if idx == indices[1] then + w_bridge:click("image_2") + elseif idx == indices[2] then + intent:start_activity(open_weather()) + elseif idx == indices[3] then + w_bridge:click("image_3") + elseif idx == indices[4] then + w_bridge:click("image_5") + elseif idx == indices[5] then + w_bridge:click("image_6") + else return + end end function on_settings() -local tab = {"Left-handed mode with weather", "Left-handed mode, no weather", "Right-handed mode with weather", "Right-handed mode, no weather" } -dialogs:show_radio_dialog("Select mode", tab, mode) + local tab = {"Left-handed mode with weather", "Left-handed mode, no weather", "Right-handed mode with weather", "Right-handed mode, no weather" } + dialogs:show_radio_dialog("Select mode", tab, mode) end function on_long_click(idx) -if idx == indices[1] then -ui:show_toast("Google search") -elseif idx == indices[2] then -ui:show_toast("Google weather") -elseif idx == indices[3] then - ui:show_toast("Google discover") -elseif idx == indices[4] then - ui:show_toast("Google voice search") -elseif idx == indices[5] then - ui:show_toast("Google Lens") -end + if idx == indices[1] then + ui:show_toast("Google search") + elseif idx == indices[2] then + ui:show_toast("Google weather") + elseif idx == indices[3] then + ui:show_toast("Google discover") + elseif idx == indices[4] then + ui:show_toast("Google voice search") + elseif idx == indices[5] then + ui:show_toast("Google Lens") + end end function on_dialog_action(data) -if data == -1 then -return -end -prefs.mode = data -on_alarm() + if data == -1 then + return + end + prefs.mode = data + on_alarm() end function setup_app_widget() local id = widgets:setup("com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.SearchWidgetProvider") - if (id ~= nil) then + if (id ~= nil) then prefs.wid = id else ui:show_text("Can't add widget") @@ -96,33 +96,33 @@ function setup_app_widget() end function set_indices() -local temp = {1, 3, 5, 7, 9} - if mode == 2 then -temp = {1, 9, 3, 5, 7} -elseif mode == 3 then -temp = reverse (temp) -elseif mode == 4 then -temp = {7, 9, 5, 3, 1} -end -return temp + local temp = {1, 3, 5, 7, 9} + if mode == 2 then + temp = {1, 9, 3, 5, 7} + elseif mode == 3 then + temp = reverse (temp) + elseif mode == 4 then + temp = {7, 9, 5, 3, 1} + end + return temp end function set_gui(tab) -local temp = tab - if mode == 2 or mode == 4 then -table.remove(tab, 3) -table.remove(tab, 3) -end -if mode > 2 then - temp = reverse(temp) -end -return temp + local temp = tab + if mode == 2 or mode == 4 then + table.remove(tab, 3) + table.remove(tab, 3) + end + if mode > 2 then + temp = reverse(temp) + end + return temp end function open_weather() -local tab ={} -tab.category = "MAIN" -tab.package = "com.google.android.googlequicksearchbox" -tab.component = "com.google.android.googlequicksearchbox/com.google.android.apps.search.weather.WeatherExportedActivity" -return tab + local tab ={} + tab.category = "MAIN" + tab.package = "com.google.android.googlequicksearchbox" + tab.component = "com.google.android.googlequicksearchbox/com.google.android.apps.search.weather.WeatherExportedActivity" + return tab end -- 2.43.0 From 0e81cb673aac5e914aa8e06ecf9f672b33302bb4 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 16 Jul 2025 06:04:53 +0800 Subject: [PATCH 199/204] Update android widget dumper --- dev/android-widget-dumper.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dev/android-widget-dumper.lua b/dev/android-widget-dumper.lua index 25c030c..80de51e 100644 --- a/dev/android-widget-dumper.lua +++ b/dev/android-widget-dumper.lua @@ -1,14 +1,16 @@ -- name = "Android widgets dumper" +-- foldable = false -- Place app package name with widget here -app_pkg = "com.weather.Weather" +app_pkg = "com.google.android.googlequicksearchbox" +--app_pkg = "com.weather.Weather" --app_pkg = "com.google.android.apps.tasks" --app_pkg = "com.android.chrome" --app_pkg = "com.whatsapp" -- Widget size (string from "1x1" to "4x4") -- In most cases you can use nil -widget_size = nil +widget_size = "4x1" -- Globals labels = {} @@ -32,7 +34,7 @@ function on_resume() if wid < 0 then ui:show_lines(labels) else - widgets:request_updates(wid) + widgets:request_updates(wid, widget_size) end end -- 2.43.0 From fd2ef7748040bb099690bef7b9f412f8c542b422 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 16 Jul 2025 06:05:44 +0800 Subject: [PATCH 200/204] Remove google search app widget --- {community => defunct}/google-search-app-widget.lua | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {community => defunct}/google-search-app-widget.lua (100%) diff --git a/community/google-search-app-widget.lua b/defunct/google-search-app-widget.lua similarity index 100% rename from community/google-search-app-widget.lua rename to defunct/google-search-app-widget.lua -- 2.43.0 From bd02082021c890151ecf69efbbc59c49fc87fd66 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Wed, 16 Jul 2025 08:46:41 +0800 Subject: [PATCH 201/204] Add info about exec and su ids --- README.md | 6 +- community/fennel-search.lua | 6783 +++++++++++++++++++++++++++++++++++ 2 files changed, 6786 insertions(+), 3 deletions(-) create mode 100644 community/fennel-search.lua diff --git a/README.md b/README.md index 581082d..79f2ed6 100644 --- a/README.md +++ b/README.md @@ -318,8 +318,8 @@ The function takes a command table of this format as a parameter: ## System * `system:open_browser(url)` - opens the specified URL in a browser or application that can handle this type of URL; -* `system:exec(string)` - executes a shell command; -* `system:su(string)` - executes a shell command as root; +* `system:exec(string, [id])` - executes a shell command; +* `system:su(string, [id])` - executes a shell command as root; * `system:location()` - returns the location in the table with two values (location request is NOT executed, the value previously saved by the system is used); * `system:request_location()` - queries the current location and returns it to the `on_location_result` callback; * `system:to_clipboard(string)` - copies the string to the clipboard; @@ -335,7 +335,7 @@ The function takes a command table of this format as a parameter: * `system:battery_info()` - returns table with battery info; * `system:system_info()` - returns table with system info. -The result of executing a shell command is sent to the `on_shell_result(string)` callback. +The result of executing a shell command is sent to the `on_shell_result(string)` or `on_shell_result_$id(string)` (_starting from AIO 5.7.5_) callback. * `system:show_notify(table)` - show system notifycation; * `system:cancel_notify()` - cancel notification. diff --git a/community/fennel-search.lua b/community/fennel-search.lua new file mode 100644 index 0000000..becc8b6 --- /dev/null +++ b/community/fennel-search.lua @@ -0,0 +1,6783 @@ +-- name = "Fennel interpreter" +-- type = "search" +-- description = "Interpreter for the Fennel language (a Lisp dialect) right in the search box!" +-- author = "Evgeny Zobnin (zobnin@gmail.com)" +-- version = "1.0" +-- aio_version = "5.7.5" + +-- SPDX-License-Identifier: MIT +-- SPDX-FileCopyrightText: Calvin Rose and contributors +package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) + local _710_ = require("fennel.utils") + local utils = _710_ + local copy = _710_["copy"] + local parser = require("fennel.parser") + local compiler = require("fennel.compiler") + local specials = require("fennel.specials") + local view = require("fennel.view") + local depth = 0 + local function prompt_for(top_3f) + if top_3f then + return (string.rep(">", (depth + 1)) .. " ") + else + return (string.rep(".", (depth + 1)) .. " ") + end + end + local function default_read_chunk(parser_state) + io.write(prompt_for((0 == parser_state["stack-size"]))) + io.flush() + local _712_0 = io.read() + if (nil ~= _712_0) then + local input = _712_0 + return (input .. "\n") + end + end + local function default_on_values(xs) + io.write(table.concat(xs, "\9")) + return io.write("\n") + end + local function default_on_error(errtype, err) + local function _715_() + local _714_0 = errtype + if (_714_0 == "Runtime") then + return (compiler.traceback(tostring(err), 4) .. "\n") + else + local _ = _714_0 + return ("%s error: %s\n"):format(errtype, tostring(err)) + end + end + return io.write(_715_()) + end + local function splice_save_locals(env, lua_source, scope) + local saves = nil + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for name in pairs(env.___replLocals___) do + local val_19_ = ("local %s = ___replLocals___[%q]"):format((scope.manglings[name] or name), name) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + saves = tbl_17_ + end + local binds = nil + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for raw, name in pairs(scope.manglings) do + local val_19_ = nil + if not scope.gensyms[name] then + val_19_ = ("___replLocals___[%q] = %s"):format(raw, name) + else + val_19_ = nil + end + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + binds = tbl_17_ + end + local gap = nil + if lua_source:find("\n") then + gap = "\n" + else + gap = " " + end + local function _721_() + if next(saves) then + return (table.concat(saves, " ") .. gap) + else + return "" + end + end + local function _724_() + local _722_0, _723_0 = lua_source:match("^(.*)[\n ](return .*)$") + if ((nil ~= _722_0) and (nil ~= _723_0)) then + local body = _722_0 + local _return = _723_0 + return (body .. gap .. table.concat(binds, " ") .. gap .. _return) + else + local _ = _722_0 + return lua_source + end + end + return (_721_() .. _724_()) + end + local commands = {} + local function completer(env, scope, text, _3ffulltext, _from, _to) + local max_items = 2000 + local seen = {} + local matches = {} + local input_fragment = text:gsub(".*[%s)(]+", "") + local stop_looking_3f = false + local function add_partials(input, tbl, prefix) + local scope_first_3f = ((tbl == env) or (tbl == env.___replLocals___)) + local tbl_17_ = matches + local i_18_ = #tbl_17_ + local function _726_() + if scope_first_3f then + return scope.manglings + else + return tbl + end + end + for k, is_mangled in utils.allpairs(_726_()) do + if (max_items <= #matches) then break end + local val_19_ = nil + do + local lookup_k = nil + if scope_first_3f then + lookup_k = is_mangled + else + lookup_k = k + end + if ((type(k) == "string") and (input == k:sub(0, #input)) and not seen[k] and ((":" ~= prefix:sub(-1)) or ("function" == type(tbl[lookup_k])))) then + seen[k] = true + val_19_ = (prefix .. k) + else + val_19_ = nil + end + end + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + return tbl_17_ + end + local function descend(input, tbl, prefix, add_matches, method_3f) + local splitter = nil + if method_3f then + splitter = "^([^:]+):(.*)" + else + splitter = "^([^.]+)%.(.*)" + end + local head, tail = input:match(splitter) + local raw_head = (scope.manglings[head] or head) + if (type(tbl[raw_head]) == "table") then + stop_looking_3f = true + if method_3f then + return add_partials(tail, tbl[raw_head], (prefix .. head .. ":")) + else + return add_matches(tail, tbl[raw_head], (prefix .. head)) + end + end + end + local function add_matches(input, tbl, prefix) + local prefix0 = nil + if prefix then + prefix0 = (prefix .. ".") + else + prefix0 = "" + end + if (not input:find("%.") and input:find(":")) then + return descend(input, tbl, prefix0, add_matches, true) + elseif not input:find("%.") then + return add_partials(input, tbl, prefix0) + else + return descend(input, tbl, prefix0, add_matches, false) + end + end + do + local _735_0 = tostring((_3ffulltext or text)):match("^%s*,([^%s()[%]]*)$") + if (nil ~= _735_0) then + local cmd_fragment = _735_0 + add_partials(cmd_fragment, commands, ",") + else + local _ = _735_0 + for _0, source in ipairs({scope.specials, scope.macros, (env.___replLocals___ or {}), env, env._G}) do + if stop_looking_3f then break end + add_matches(input_fragment, source) + end + end + end + return matches + end + local function command_3f(input) + return input:match("^%s*,") + end + local function command_docs() + local _737_ + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for name, f in utils.stablepairs(commands) do + local val_19_ = (" ,%s - %s"):format(name, ((compiler.metadata):get(f, "fnl/docstring") or "undocumented")) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + _737_ = tbl_17_ + end + return table.concat(_737_, "\n") + end + commands.help = function(_, _0, on_values) + return on_values({("Welcome to Fennel.\nThis is the REPL where you can enter code to be evaluated.\nYou can also run these repl commands:\n\n" .. command_docs() .. "\n ,return FORM - Evaluate FORM and return its value to the REPL's caller.\n ,exit - Leave the repl.\n\nUse ,doc something to see descriptions for individual macros and special forms.\nValues from previous inputs are kept in *1, *2, and *3.\n\nFor more information about the language, see https://fennel-lang.org/reference")}) + end + do end (compiler.metadata):set(commands.help, "fnl/docstring", "Show this message.") + local function reload(module_name, env, on_values, on_error) + local _739_0, _740_0 = pcall(specials["load-code"]("return require(...)", env), module_name) + if ((_739_0 == true) and (nil ~= _740_0)) then + local old = _740_0 + local _ = nil + package.loaded[module_name] = nil + _ = nil + local new = nil + do + local _741_0, _742_0 = pcall(require, module_name) + if ((_741_0 == true) and (nil ~= _742_0)) then + local new0 = _742_0 + new = new0 + elseif (true and (nil ~= _742_0)) then + local _0 = _741_0 + local msg = _742_0 + on_error("Repl", msg) + new = old + else + new = nil + end + end + specials["macro-loaded"][module_name] = nil + if ((type(old) == "table") and (type(new) == "table")) then + for k, v in pairs(new) do + old[k] = v + end + for k in pairs(old) do + if (nil == new[k]) then + old[k] = nil + end + end + package.loaded[module_name] = old + end + return on_values({"ok"}) + elseif ((_739_0 == false) and (nil ~= _740_0)) then + local msg = _740_0 + if msg:match("loop or previous error loading module") then + package.loaded[module_name] = nil + return reload(module_name, env, on_values, on_error) + elseif specials["macro-loaded"][module_name] then + specials["macro-loaded"][module_name] = nil + return nil + else + local function _747_() + local _746_0 = msg:gsub("\n.*", "") + return _746_0 + end + return on_error("Runtime", _747_()) + end + end + end + local function run_command(read, on_error, f) + local _750_0, _751_0, _752_0 = pcall(read) + if ((_750_0 == true) and (_751_0 == true) and (nil ~= _752_0)) then + local val = _752_0 + local _753_0, _754_0 = pcall(f, val) + if ((_753_0 == false) and (nil ~= _754_0)) then + local msg = _754_0 + return on_error("Runtime", msg) + end + elseif (_750_0 == false) then + return on_error("Parse", "Couldn't parse input.") + end + end + commands.reload = function(env, read, on_values, on_error) + local function _757_(_241) + return reload(tostring(_241), env, on_values, on_error) + end + return run_command(read, on_error, _757_) + end + do end (compiler.metadata):set(commands.reload, "fnl/docstring", "Reload the specified module.") + commands.reset = function(env, _, on_values) + env.___replLocals___ = {} + return on_values({"ok"}) + end + do end (compiler.metadata):set(commands.reset, "fnl/docstring", "Erase all repl-local scope.") + commands.complete = function(env, read, on_values, on_error, scope, chars) + local function _758_() + return on_values(completer(env, scope, table.concat(chars):gsub("^%s*,complete%s+", ""):sub(1, -2))) + end + return run_command(read, on_error, _758_) + end + do end (compiler.metadata):set(commands.complete, "fnl/docstring", "Print all possible completions for a given input symbol.") + local function apropos_2a(pattern, tbl, prefix, seen, names) + for name, subtbl in pairs(tbl) do + if (("string" == type(name)) and (package ~= subtbl)) then + local _759_0 = type(subtbl) + if (_759_0 == "function") then + if ((prefix .. name)):match(pattern) then + table.insert(names, (prefix .. name)) + end + elseif (_759_0 == "table") then + if not seen[subtbl] then + local _761_ + do + seen[subtbl] = true + _761_ = seen + end + apropos_2a(pattern, subtbl, (prefix .. name:gsub("%.", "/") .. "."), _761_, names) + end + end + end + end + return names + end + local function apropos(pattern) + return apropos_2a(pattern:gsub("^_G%.", ""), package.loaded, "", {}, {}) + end + commands.apropos = function(_env, read, on_values, on_error, _scope) + local function _765_(_241) + return on_values(apropos(tostring(_241))) + end + return run_command(read, on_error, _765_) + end + do end (compiler.metadata):set(commands.apropos, "fnl/docstring", "Print all functions matching a pattern in all loaded modules.") + local function apropos_follow_path(path) + local paths = nil + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for p in path:gmatch("[^%.]+") do + local val_19_ = p + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + paths = tbl_17_ + end + local tgt = package.loaded + for _, path0 in ipairs(paths) do + if (nil == tgt) then break end + local _768_ + do + local _767_0 = path0:gsub("%/", ".") + _768_ = _767_0 + end + tgt = tgt[_768_] + end + return tgt + end + local function apropos_doc(pattern) + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for _, path in ipairs(apropos(".*")) do + local val_19_ = nil + do + local tgt = apropos_follow_path(path) + if ("function" == type(tgt)) then + local _769_0 = (compiler.metadata):get(tgt, "fnl/docstring") + if (nil ~= _769_0) then + local docstr = _769_0 + val_19_ = (docstr:match(pattern) and path) + else + val_19_ = nil + end + else + val_19_ = nil + end + end + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + return tbl_17_ + end + commands["apropos-doc"] = function(_env, read, on_values, on_error, _scope) + local function _773_(_241) + return on_values(apropos_doc(tostring(_241))) + end + return run_command(read, on_error, _773_) + end + do end (compiler.metadata):set(commands["apropos-doc"], "fnl/docstring", "Print all functions that match the pattern in their docs") + local function apropos_show_docs(on_values, pattern) + for _, path in ipairs(apropos(pattern)) do + local tgt = apropos_follow_path(path) + if (("function" == type(tgt)) and (compiler.metadata):get(tgt, "fnl/docstring")) then + on_values({specials.doc(tgt, path)}) + on_values({}) + end + end + return nil + end + commands["apropos-show-docs"] = function(_env, read, on_values, on_error) + local function _775_(_241) + return apropos_show_docs(on_values, tostring(_241)) + end + return run_command(read, on_error, _775_) + end + do end (compiler.metadata):set(commands["apropos-show-docs"], "fnl/docstring", "Print all documentations matching a pattern in function name") + local function resolve(identifier, _776_0, scope) + local _777_ = _776_0 + local env = _777_ + local ___replLocals___ = _777_["___replLocals___"] + local e = nil + local function _778_(_241, _242) + return (___replLocals___[scope.unmanglings[_242]] or env[_242]) + end + e = setmetatable({}, {__index = _778_}) + local function _779_(...) + local _780_0, _781_0 = ... + if ((_780_0 == true) and (nil ~= _781_0)) then + local code = _781_0 + local function _782_(...) + local _783_0, _784_0 = ... + if ((_783_0 == true) and (nil ~= _784_0)) then + local val = _784_0 + return val + else + local _ = _783_0 + return nil + end + end + return _782_(pcall(specials["load-code"](code, e))) + else + local _ = _780_0 + return nil + end + end + return _779_(pcall(compiler["compile-string"], tostring(identifier), {scope = scope})) + end + commands.find = function(env, read, on_values, on_error, scope) + local function _787_(_241) + local _788_0 = nil + do + local _789_0 = utils["sym?"](_241) + if (nil ~= _789_0) then + local _790_0 = resolve(_789_0, env, scope) + if (nil ~= _790_0) then + _788_0 = debug.getinfo(_790_0) + else + _788_0 = _790_0 + end + else + _788_0 = _789_0 + end + end + if ((_G.type(_788_0) == "table") and (nil ~= _788_0.linedefined) and (nil ~= _788_0.short_src) and (nil ~= _788_0.source) and (_788_0.what == "Lua")) then + local line = _788_0.linedefined + local src = _788_0.short_src + local source = _788_0.source + local fnlsrc = nil + do + local _793_0 = compiler.sourcemap + if (nil ~= _793_0) then + _793_0 = _793_0[source] + end + if (nil ~= _793_0) then + _793_0 = _793_0[line] + end + if (nil ~= _793_0) then + _793_0 = _793_0[2] + end + fnlsrc = _793_0 + end + return on_values({string.format("%s:%s", src, (fnlsrc or line))}) + elseif (_788_0 == nil) then + return on_error("Repl", "Unknown value") + else + local _ = _788_0 + return on_error("Repl", "No source info") + end + end + return run_command(read, on_error, _787_) + end + do end (compiler.metadata):set(commands.find, "fnl/docstring", "Print the filename and line number for a given function") + commands.doc = function(env, read, on_values, on_error, scope) + local function _798_(_241) + local name = tostring(_241) + local path = (utils["multi-sym?"](name) or {name}) + local ok_3f, target = nil, nil + local function _799_() + return (scope.specials[name] or utils["get-in"](scope.macros, path) or resolve(name, env, scope)) + end + ok_3f, target = pcall(_799_) + if ok_3f then + return on_values({specials.doc(target, name)}) + else + return on_error("Repl", ("Could not find " .. name .. " for docs.")) + end + end + return run_command(read, on_error, _798_) + end + do end (compiler.metadata):set(commands.doc, "fnl/docstring", "Print the docstring and arglist for a function, macro, or special form.") + commands.compile = function(_, read, on_values, on_error, _0, _1, opts) + local function _801_(_241) + local _802_0, _803_0 = pcall(compiler.compile, _241, opts) + if ((_802_0 == true) and (nil ~= _803_0)) then + local result = _803_0 + return on_values({result}) + elseif (true and (nil ~= _803_0)) then + local _2 = _802_0 + local msg = _803_0 + return on_error("Repl", ("Error compiling expression: " .. msg)) + end + end + return run_command(read, on_error, _801_) + end + do end (compiler.metadata):set(commands.compile, "fnl/docstring", "compiles the expression into lua and prints the result.") + local function load_plugin_commands(plugins) + for i = #(plugins or {}), 1, -1 do + for name, f in pairs(plugins[i]) do + local _805_0 = name:match("^repl%-command%-(.*)") + if (nil ~= _805_0) then + local cmd_name = _805_0 + commands[cmd_name] = f + end + end + end + return nil + end + local function run_command_loop(input, read, loop, env, on_values, on_error, scope, chars, opts) + local command_name = input:match(",([^%s/]+)") + do + local _807_0 = commands[command_name] + if (nil ~= _807_0) then + local command = _807_0 + command(env, read, on_values, on_error, scope, chars, opts) + else + local _ = _807_0 + if ((command_name ~= "exit") and (command_name ~= "return")) then + on_values({"Unknown command", command_name}) + end + end + end + if ("exit" ~= command_name) then + return loop((command_name == "return")) + end + end + local function try_readline_21(opts, ok, readline) + if ok then + if readline.set_readline_name then + readline.set_readline_name("fennel") + end + readline.set_options({histfile = "", keeplines = 1000}) + opts.readChunk = function(parser_state) + local _812_0 = readline.readline(prompt_for((0 == parser_state["stack-size"]))) + if (nil ~= _812_0) then + local input = _812_0 + return (input .. "\n") + end + end + local completer0 = nil + opts.registerCompleter = function(repl_completer) + completer0 = repl_completer + return nil + end + local function repl_completer(text, from, to) + if completer0 then + readline.set_completion_append_character("") + return completer0(text:sub(from, to), text, from, to) + else + return {} + end + end + readline.set_complete_function(repl_completer) + return readline + end + end + local function should_use_readline_3f(opts) + return (("dumb" ~= os.getenv("TERM")) and not opts.readChunk and not opts.registerCompleter) + end + local function repl(_3foptions) + local old_root_options = utils.root.options + local _816_ = copy(_3foptions) + local opts = _816_ + local _3ffennelrc = _816_["fennelrc"] + local _ = nil + opts.fennelrc = nil + _ = nil + local readline = (should_use_readline_3f(opts) and try_readline_21(opts, pcall(require, "readline"))) + local _0 = nil + if _3ffennelrc then + _0 = _3ffennelrc() + else + _0 = nil + end + local env = specials["wrap-env"]((opts.env or rawget(_G, "_ENV") or _G)) + local callbacks = {["view-opts"] = (opts["view-opts"] or {depth = 4}), env = env, onError = (opts.onError or default_on_error), onValues = (opts.onValues or default_on_values), pp = (opts.pp or view), readChunk = (opts.readChunk or default_read_chunk)} + local save_locals_3f = (opts.saveLocals ~= false) + local byte_stream, clear_stream = nil, nil + local function _818_(_241) + return callbacks.readChunk(_241) + end + byte_stream, clear_stream = parser.granulate(_818_) + local chars = {} + local read, reset = nil, nil + local function _819_(parser_state) + local b = byte_stream(parser_state) + if b then + table.insert(chars, string.char(b)) + end + return b + end + read, reset = parser.parser(_819_) + depth = (depth + 1) + if opts.message then + callbacks.onValues({opts.message}) + end + env.___repl___ = callbacks + opts.env, opts.scope = env, compiler["make-scope"]() + opts.useMetadata = (opts.useMetadata ~= false) + if (opts.allowedGlobals == nil) then + opts.allowedGlobals = specials["current-global-names"](env) + end + if opts.init then + opts.init(opts, depth) + end + if opts.registerCompleter then + local function _825_() + local _824_0 = opts.scope + local function _826_(...) + return completer(env, _824_0, ...) + end + return _826_ + end + opts.registerCompleter(_825_()) + end + load_plugin_commands(opts.plugins) + if save_locals_3f then + local function newindex(t, k, v) + if opts.scope.manglings[k] then + return rawset(t, k, v) + end + end + env.___replLocals___ = setmetatable({}, {__newindex = newindex}) + end + local function print_values(...) + local vals = {...} + local out = {} + local pp = callbacks.pp + env._, env.__ = vals[1], vals + for i = 1, select("#", ...) do + table.insert(out, pp(vals[i], callbacks["view-opts"])) + end + return callbacks.onValues(out) + end + local function save_value(...) + env.___replLocals___["*3"] = env.___replLocals___["*2"] + env.___replLocals___["*2"] = env.___replLocals___["*1"] + env.___replLocals___["*1"] = ... + return ... + end + opts.scope.manglings["*1"], opts.scope.unmanglings._1 = "_1", "*1" + opts.scope.manglings["*2"], opts.scope.unmanglings._2 = "_2", "*2" + opts.scope.manglings["*3"], opts.scope.unmanglings._3 = "_3", "*3" + local function loop(exit_next_3f) + for k in pairs(chars) do + chars[k] = nil + end + reset() + local ok, parser_not_eof_3f, form = pcall(read) + local src_string = table.concat(chars) + local readline_not_eof_3f = (not readline or (src_string ~= "(null)")) + local not_eof_3f = (readline_not_eof_3f and parser_not_eof_3f) + if not ok then + callbacks.onError("Parse", not_eof_3f) + clear_stream() + return loop() + elseif command_3f(src_string) then + return run_command_loop(src_string, read, loop, env, callbacks.onValues, callbacks.onError, opts.scope, chars, opts) + else + if not_eof_3f then + local function _830_(...) + local _831_0, _832_0 = ... + if ((_831_0 == true) and (nil ~= _832_0)) then + local src = _832_0 + local function _833_(...) + local _834_0, _835_0 = ... + if ((_834_0 == true) and (nil ~= _835_0)) then + local chunk = _835_0 + local function _836_() + return print_values(save_value(chunk())) + end + local function _837_(...) + return callbacks.onError("Runtime", ...) + end + return xpcall(_836_, _837_) + elseif ((_834_0 == false) and (nil ~= _835_0)) then + local msg = _835_0 + clear_stream() + return callbacks.onError("Compile", msg) + end + end + local function _840_(...) + local src0 = nil + if save_locals_3f then + src0 = splice_save_locals(env, src, opts.scope) + else + src0 = src + end + return pcall(specials["load-code"], src0, env) + end + return _833_(_840_(...)) + elseif ((_831_0 == false) and (nil ~= _832_0)) then + local msg = _832_0 + clear_stream() + return callbacks.onError("Compile", msg) + end + end + local function _842_() + opts["source"] = src_string + return opts + end + _830_(pcall(compiler.compile, form, _842_())) + utils.root.options = old_root_options + if exit_next_3f then + return env.___replLocals___["*1"] + else + return loop() + end + end + end + end + local value = loop() + depth = (depth - 1) + if readline then + readline.save_history() + end + if opts.exit then + opts.exit(opts, depth) + end + return value + end + local repl_mt = {__index = {repl = repl}} + repl_mt.__call = function(_848_0, _3fopts) + local _849_ = _848_0 + local overrides = _849_ + local view_opts = _849_["view-opts"] + local opts = copy(_3fopts, copy(overrides)) + local _851_ + do + local _850_0 = _3fopts + if (nil ~= _850_0) then + _850_0 = _850_0["view-opts"] + end + _851_ = _850_0 + end + opts["view-opts"] = copy(_851_, copy(view_opts)) + return repl(opts) + end + return setmetatable({["view-opts"] = {}}, repl_mt) +end +package.preload["fennel.specials"] = package.preload["fennel.specials"] or function(...) + local _484_ = require("fennel.utils") + local utils = _484_ + local pack = _484_["pack"] + local unpack = _484_["unpack"] + local view = require("fennel.view") + local parser = require("fennel.parser") + local compiler = require("fennel.compiler") + local SPECIALS = compiler.scopes.global.specials + local function str1(x) + return tostring(x[1]) + end + local function wrap_env(env) + local function _485_(_, key) + if utils["string?"](key) then + return env[compiler["global-unmangling"](key)] + else + return env[key] + end + end + local function _487_(_, key, value) + if utils["string?"](key) then + env[compiler["global-unmangling"](key)] = value + return nil + else + env[key] = value + return nil + end + end + local function _489_() + local _490_ + do + local tbl_14_ = {} + for k, v in utils.stablepairs(env) do + local k_15_, v_16_ = nil, nil + local _491_ + if utils["string?"](k) then + _491_ = compiler["global-unmangling"](k) + else + _491_ = k + end + k_15_, v_16_ = _491_, v + if ((k_15_ ~= nil) and (v_16_ ~= nil)) then + tbl_14_[k_15_] = v_16_ + end + end + _490_ = tbl_14_ + end + return next, _490_, nil + end + return setmetatable({}, {__index = _485_, __newindex = _487_, __pairs = _489_}) + end + local function fennel_module_name() + return (utils.root.options.moduleName or "fennel") + end + local function current_global_names(_3fenv) + local mt = nil + do + local _494_0 = getmetatable(_3fenv) + if ((_G.type(_494_0) == "table") and (nil ~= _494_0.__pairs)) then + local mtpairs = _494_0.__pairs + local tbl_14_ = {} + for k, v in mtpairs(_3fenv) do + local k_15_, v_16_ = k, v + if ((k_15_ ~= nil) and (v_16_ ~= nil)) then + tbl_14_[k_15_] = v_16_ + end + end + mt = tbl_14_ + elseif (_494_0 == nil) then + mt = (_3fenv or _G) + else + mt = nil + end + end + local function _497_() + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for k in utils.stablepairs(mt) do + local val_19_ = compiler["global-unmangling"](k) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + return tbl_17_ + end + return (mt and _497_()) + end + local function load_code(code, _3fenv, _3ffilename) + local env = (_3fenv or rawget(_G, "_ENV") or _G) + local _499_0, _500_0 = rawget(_G, "setfenv"), rawget(_G, "loadstring") + if ((nil ~= _499_0) and (nil ~= _500_0)) then + local setfenv = _499_0 + local loadstring = _500_0 + local f = assert(loadstring(code, _3ffilename)) + setfenv(f, env) + return f + else + local _ = _499_0 + return assert(load(code, _3ffilename, "t", env)) + end + end + local function v__3edocstring(tgt) + return (((compiler.metadata):get(tgt, "fnl/docstring") or "#")):gsub("\n$", ""):gsub("\n", "\n ") + end + local function doc_2a(tgt, name) + assert(("string" == type(name)), "name must be a string") + if not tgt then + return (name .. " not found") + else + local function _503_() + local _502_0 = getmetatable(tgt) + if ((_G.type(_502_0) == "table") and true) then + local __call = _502_0.__call + return ("function" == type(__call)) + end + end + if ((type(tgt) == "function") or _503_()) then + local elts = {name, unpack(((compiler.metadata):get(tgt, "fnl/arglist") or {"#"}))} + return string.format("(%s)\n %s", table.concat(elts, " "), v__3edocstring(tgt)) + else + return string.format("%s\n %s", name, v__3edocstring(tgt)) + end + end + end + local function doc_special(name, arglist, docstring, body_form_3f) + compiler.metadata[SPECIALS[name]] = {["fnl/arglist"] = arglist, ["fnl/body-form?"] = body_form_3f, ["fnl/docstring"] = docstring} + return nil + end + local function compile_do(ast, scope, parent, _3fstart) + local start = (_3fstart or 2) + local len = #ast + local sub_scope = compiler["make-scope"](scope) + for i = start, len do + compiler.compile1(ast[i], sub_scope, parent, {nval = 0}) + end + return nil + end + SPECIALS["do"] = function(ast, scope, parent, opts, _3fstart, _3fchunk, _3fsub_scope, _3fpre_syms) + local start = (_3fstart or 2) + local sub_scope = (_3fsub_scope or compiler["make-scope"](scope)) + local chunk = (_3fchunk or {}) + local len = #ast + local retexprs = {returned = true} + utils.hook("pre-do", ast, sub_scope) + local function compile_body(outer_target, outer_tail, outer_retexprs) + for i = start, len do + local subopts = {nval = (((i ~= len) and 0) or opts.nval), tail = (((i == len) and outer_tail) or nil), target = (((i == len) and outer_target) or nil)} + local _ = utils["propagate-options"](opts, subopts) + local subexprs = compiler.compile1(ast[i], sub_scope, chunk, subopts) + if (i ~= len) then + compiler["keep-side-effects"](subexprs, parent, nil, ast[i]) + end + end + compiler.emit(parent, chunk, ast) + compiler.emit(parent, "end", ast) + utils.hook("do", ast, sub_scope) + return (outer_retexprs or retexprs) + end + if (opts.target or (opts.nval == 0) or opts.tail) then + compiler.emit(parent, "do", ast) + return compile_body(opts.target, opts.tail) + elseif opts.nval then + local syms = {} + for i = 1, opts.nval do + local s = ((_3fpre_syms and _3fpre_syms[i]) or compiler.gensym(scope)) + syms[i] = s + retexprs[i] = utils.expr(s, "sym") + end + local outer_target = table.concat(syms, ", ") + compiler.emit(parent, string.format("local %s", outer_target), ast) + compiler.emit(parent, "do", ast) + return compile_body(outer_target, opts.tail) + else + local fname = compiler.gensym(scope) + local fargs = nil + if scope.vararg then + fargs = "..." + else + fargs = "" + end + compiler.emit(parent, string.format("local function %s(%s)", fname, fargs), ast) + return compile_body(nil, true, utils.expr((fname .. "(" .. fargs .. ")"), "statement")) + end + end + doc_special("do", {"..."}, "Evaluate multiple forms; return last value.", true) + local function iter_args(ast) + local ast0, len, i = ast, #ast, 1 + local function _509_() + i = (1 + i) + while ((i == len) and utils["call-of?"](ast0[i], "values")) do + ast0 = ast0[i] + len = #ast0 + i = 2 + end + return ast0[i], (nil == ast0[(i + 1)]) + end + return _509_ + end + SPECIALS.values = function(ast, scope, parent) + local exprs = {} + for subast, last_3f in iter_args(ast) do + local subexprs = compiler.compile1(subast, scope, parent, {nval = (not last_3f and 1)}) + table.insert(exprs, subexprs[1]) + if last_3f then + for j = 2, #subexprs do + table.insert(exprs, subexprs[j]) + end + end + end + return exprs + end + doc_special("values", {"..."}, "Return multiple values from a function. Must be in tail position.") + local function __3estack(stack, tbl) + for k, v in pairs(tbl) do + table.insert(stack, k) + table.insert(stack, v) + end + return stack + end + local function literal_3f(val) + local res = true + if utils["list?"](val) then + res = false + elseif utils["table?"](val) then + local stack = __3estack({}, val) + for _, elt in ipairs(stack) do + if not res then break end + if utils["list?"](elt) then + res = false + elseif utils["table?"](elt) then + __3estack(stack, elt) + end + end + end + return res + end + local function compile_value(v) + local opts = {nval = 1, tail = false} + local scope = compiler["make-scope"]() + local chunk = {} + local _513_ = compiler.compile1(v, scope, chunk, opts) + local _514_ = _513_[1] + local v0 = _514_[1] + return v0 + end + local function insert_meta(meta, k, v) + local view_opts = {["escape-newlines?"] = true, ["line-length"] = math.huge, ["one-line?"] = true} + compiler.assert((type(k) == "string"), ("expected string keys in metadata table, got: %s"):format(view(k, view_opts))) + compiler.assert(literal_3f(v), ("expected literal value in metadata table, got: %s %s"):format(view(k, view_opts), view(v, view_opts))) + table.insert(meta, view(k)) + local function _515_() + if ("string" == type(v)) then + return view(v, view_opts) + else + return compile_value(v) + end + end + table.insert(meta, _515_()) + return meta + end + local function insert_arglist(meta, arg_list) + local opts = {["escape-newlines?"] = true, ["line-length"] = math.huge, ["one-line?"] = true} + local view_args = nil + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for _, arg in ipairs(arg_list) do + local val_19_ = view(view(arg, opts)) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + view_args = tbl_17_ + end + table.insert(meta, "\"fnl/arglist\"") + table.insert(meta, ("{" .. table.concat(view_args, ", ") .. "}")) + return meta + end + local function set_fn_metadata(f_metadata, parent, fn_name) + if utils.root.options.useMetadata then + local meta_fields = {} + for k, v in utils.stablepairs(f_metadata) do + if (k == "fnl/arglist") then + insert_arglist(meta_fields, v) + else + insert_meta(meta_fields, k, v) + end + end + if (type(utils.root.options.useMetadata) == "string") then + return compiler.emit(parent, ("%s:setall(%s, %s)"):format(utils.root.options.useMetadata, fn_name, table.concat(meta_fields, ", "))) + else + local meta_str = ("require(\"%s\").metadata"):format(fennel_module_name()) + return compiler.emit(parent, ("pcall(function() %s:setall(%s, %s) end)"):format(meta_str, fn_name, table.concat(meta_fields, ", "))) + end + end + end + local function get_fn_name(ast, scope, fn_name, multi) + if (fn_name and (fn_name[1] ~= "nil")) then + local _520_ + if not multi then + _520_ = compiler["declare-local"](fn_name, scope, ast) + else + _520_ = compiler["symbol-to-expression"](fn_name, scope)[1] + end + return _520_, not multi, 3 + else + return nil, true, 2 + end + end + local function compile_named_fn(ast, f_scope, f_chunk, parent, index, fn_name, local_3f, arg_name_list, f_metadata) + utils.hook("pre-fn", ast, f_scope, parent) + for i = (index + 1), #ast do + compiler.compile1(ast[i], f_scope, f_chunk, {nval = (((i ~= #ast) and 0) or nil), tail = (i == #ast)}) + end + local _523_ + if local_3f then + _523_ = "local function %s(%s)" + else + _523_ = "%s = function(%s)" + end + compiler.emit(parent, string.format(_523_, fn_name, table.concat(arg_name_list, ", ")), ast) + compiler.emit(parent, f_chunk, ast) + compiler.emit(parent, "end", ast) + set_fn_metadata(f_metadata, parent, fn_name) + utils.hook("fn", ast, f_scope, parent) + return utils.expr(fn_name, "sym") + end + local function compile_anonymous_fn(ast, f_scope, f_chunk, parent, index, arg_name_list, f_metadata, scope) + local fn_name = compiler.gensym(scope) + return compile_named_fn(ast, f_scope, f_chunk, parent, index, fn_name, true, arg_name_list, f_metadata) + end + local function maybe_metadata(ast, pred, handler, mt, index) + local index_2a = (index + 1) + local index_2a_before_ast_end_3f = (index_2a < #ast) + local expr = ast[index_2a] + if (index_2a_before_ast_end_3f and pred(expr)) then + return handler(mt, expr), index_2a + else + return mt, index + end + end + local function get_function_metadata(ast, arg_list, index) + local function _526_(_241, _242) + local tbl_14_ = _241 + for k, v in pairs(_242) do + local k_15_, v_16_ = k, v + if ((k_15_ ~= nil) and (v_16_ ~= nil)) then + tbl_14_[k_15_] = v_16_ + end + end + return tbl_14_ + end + local function _528_(_241, _242) + _241["fnl/docstring"] = _242 + return _241 + end + return maybe_metadata(ast, utils["kv-table?"], _526_, maybe_metadata(ast, utils["string?"], _528_, {["fnl/arglist"] = arg_list}, index)) + end + SPECIALS.fn = function(ast, scope, parent, opts) + local f_scope = nil + do + local _529_0 = compiler["make-scope"](scope) + _529_0["vararg"] = false + f_scope = _529_0 + end + local f_chunk = {} + local fn_sym = utils["sym?"](ast[2]) + local multi = (fn_sym and utils["multi-sym?"](fn_sym[1])) + local fn_name, local_3f, index = get_fn_name(ast, scope, fn_sym, multi, opts) + local arg_list = compiler.assert(utils["table?"](ast[index]), "expected parameters table", ast) + compiler.assert((not multi or not multi["multi-sym-method-call"]), ("unexpected multi symbol " .. tostring(fn_name)), fn_sym) + if (multi and not scope.symmeta[multi[1]] and not compiler["global-allowed?"](multi[1])) then + compiler.assert(nil, ("expected local table " .. multi[1]), ast[2]) + end + local function destructure_arg(arg) + local raw = utils.sym(compiler.gensym(scope)) + local declared = compiler["declare-local"](raw, f_scope, ast) + compiler.destructure(arg, raw, ast, f_scope, f_chunk, {declaration = true, nomulti = true, symtype = "arg"}) + return declared + end + local function destructure_amp(i) + compiler.assert((i == (#arg_list - 1)), "expected rest argument before last parameter", arg_list[(i + 1)], arg_list) + f_scope.vararg = true + compiler.destructure(arg_list[#arg_list], {utils.varg()}, ast, f_scope, f_chunk, {declaration = true, nomulti = true, symtype = "arg"}) + return "..." + end + local function get_arg_name(arg, i) + if f_scope.vararg then + return nil + elseif utils["varg?"](arg) then + compiler.assert((arg == arg_list[#arg_list]), "expected vararg as last parameter", ast) + f_scope.vararg = true + return "..." + elseif utils["sym?"](arg, "&") then + return destructure_amp(i) + elseif (utils["sym?"](arg) and (tostring(arg) ~= "nil") and not utils["multi-sym?"](tostring(arg))) then + return compiler["declare-local"](arg, f_scope, ast) + elseif utils["table?"](arg) then + return destructure_arg(arg) + else + return compiler.assert(false, ("expected symbol for function parameter: %s"):format(tostring(arg)), ast[index]) + end + end + local arg_name_list = nil + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for i, a in ipairs(arg_list) do + local val_19_ = get_arg_name(a, i) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + arg_name_list = tbl_17_ + end + local f_metadata, index0 = get_function_metadata(ast, arg_list, index) + if fn_name then + return compile_named_fn(ast, f_scope, f_chunk, parent, index0, fn_name, local_3f, arg_name_list, f_metadata) + else + return compile_anonymous_fn(ast, f_scope, f_chunk, parent, index0, arg_name_list, f_metadata, scope) + end + end + doc_special("fn", {"name?", "args", "docstring?", "..."}, "Function syntax. May optionally include a name and docstring or a metadata table.\nIf a name is provided, the function will be bound in the current scope.\nWhen called with the wrong number of args, excess args will be discarded\nand lacking args will be nil, use lambda for arity-checked functions.", true) + SPECIALS.lua = function(ast, _, parent) + compiler.assert(((#ast == 2) or (#ast == 3)), "expected 1 or 2 arguments", ast) + local _535_ + do + local _534_0 = utils["sym?"](ast[2]) + if (nil ~= _534_0) then + _535_ = tostring(_534_0) + else + _535_ = _534_0 + end + end + if ("nil" ~= _535_) then + table.insert(parent, {ast = ast, leaf = tostring(ast[2])}) + end + local _539_ + do + local _538_0 = utils["sym?"](ast[3]) + if (nil ~= _538_0) then + _539_ = tostring(_538_0) + else + _539_ = _538_0 + end + end + if ("nil" ~= _539_) then + return tostring(ast[3]) + end + end + local function dot(ast, scope, parent) + compiler.assert((1 < #ast), "expected table argument", ast) + local len = #ast + local lhs_node = compiler.macroexpand(ast[2], scope) + local _542_ = compiler.compile1(lhs_node, scope, parent, {nval = 1}) + local lhs = _542_[1] + if (len == 2) then + return tostring(lhs) + else + local indices = {} + for i = 3, len do + local index = ast[i] + if (utils["string?"](index) and utils["valid-lua-identifier?"](index)) then + table.insert(indices, ("." .. index)) + else + local _543_ = compiler.compile1(index, scope, parent, {nval = 1}) + local index0 = _543_[1] + table.insert(indices, ("[" .. tostring(index0) .. "]")) + end + end + if (not (utils["sym?"](lhs_node) or utils["list?"](lhs_node)) or ("nil" == tostring(lhs_node))) then + return ("(" .. tostring(lhs) .. ")" .. table.concat(indices)) + else + return (tostring(lhs) .. table.concat(indices)) + end + end + end + SPECIALS["."] = dot + doc_special(".", {"tbl", "key1", "..."}, "Look up key1 in tbl table. If more args are provided, do a nested lookup.") + SPECIALS.global = function(ast, scope, parent) + compiler.assert((#ast == 3), "expected name and value", ast) + compiler.destructure(ast[2], ast[3], ast, scope, parent, {forceglobal = true, nomulti = true, symtype = "global"}) + return nil + end + doc_special("global", {"name", "val"}, "Set name as a global with val. Deprecated.") + SPECIALS.set = function(ast, scope, parent) + compiler.assert((#ast == 3), "expected name and value", ast) + compiler.destructure(ast[2], ast[3], ast, scope, parent, {noundef = true, symtype = "set"}) + return nil + end + doc_special("set", {"name", "val"}, "Set a local variable to a new value. Only works on locals using var.") + local function set_forcibly_21_2a(ast, scope, parent) + compiler.assert((#ast == 3), "expected name and value", ast) + compiler.destructure(ast[2], ast[3], ast, scope, parent, {forceset = true, symtype = "set"}) + return nil + end + SPECIALS["set-forcibly!"] = set_forcibly_21_2a + local function local_2a(ast, scope, parent, opts) + compiler.assert(((0 == opts.nval) or opts.tail), "can't introduce local here", ast) + compiler.assert((#ast == 3), "expected name and value", ast) + compiler.destructure(ast[2], ast[3], ast, scope, parent, {declaration = true, nomulti = true, symtype = "local"}) + return nil + end + SPECIALS["local"] = local_2a + doc_special("local", {"name", "val"}, "Introduce new top-level immutable local.") + SPECIALS.var = function(ast, scope, parent, opts) + compiler.assert(((0 == opts.nval) or opts.tail), "can't introduce var here", ast) + compiler.assert((#ast == 3), "expected name and value", ast) + compiler.destructure(ast[2], ast[3], ast, scope, parent, {declaration = true, isvar = true, nomulti = true, symtype = "var"}) + return nil + end + doc_special("var", {"name", "val"}, "Introduce new mutable local.") + local function kv_3f(t) + local _547_ + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for k in pairs(t) do + local val_19_ = nil + if ("number" ~= type(k)) then + val_19_ = k + else + val_19_ = nil + end + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + _547_ = tbl_17_ + end + return _547_[1] + end + SPECIALS.let = function(_550_0, scope, parent, opts) + local _551_ = _550_0 + local _ = _551_[1] + local bindings = _551_[2] + local ast = _551_ + compiler.assert((utils["table?"](bindings) and not kv_3f(bindings)), "expected binding sequence", (bindings or ast[1])) + compiler.assert(((#bindings % 2) == 0), "expected even number of name/value bindings", bindings) + compiler.assert((3 <= #ast), "expected body expression", ast[1]) + local pre_syms = nil + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for _0 = 1, (opts.nval or 0) do + local val_19_ = compiler.gensym(scope) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + pre_syms = tbl_17_ + end + local sub_scope = compiler["make-scope"](scope) + local sub_chunk = {} + for i = 1, #bindings, 2 do + compiler.destructure(bindings[i], bindings[(i + 1)], ast, sub_scope, sub_chunk, {declaration = true, nomulti = true, symtype = "let"}) + end + return SPECIALS["do"](ast, scope, parent, opts, 3, sub_chunk, sub_scope, pre_syms) + end + doc_special("let", {"[name1 val1 ... nameN valN]", "..."}, "Introduces a new scope in which a given set of local bindings are used.", true) + local function get_prev_line(parent) + if ("table" == type(parent)) then + return get_prev_line((parent.leaf or parent[#parent])) + else + return (parent or "") + end + end + local function needs_separator_3f(root, prev_line) + return (root:match("^%(") and prev_line and not prev_line:find(" end$")) + end + SPECIALS.tset = function(ast, scope, parent) + compiler.assert((3 < #ast), "expected table, key, and value arguments", ast) + compiler.assert(((type(ast[2]) ~= "boolean") and (type(ast[2]) ~= "number")), "cannot set field of literal value", ast) + local root = str1(compiler.compile1(ast[2], scope, parent, {nval = 1})) + local root0 = nil + if root:match("^[.{\"]") then + root0 = string.format("(%s)", root) + else + root0 = root + end + local keys = nil + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for i = 3, (#ast - 1) do + local val_19_ = str1(compiler.compile1(ast[i], scope, parent, {nval = 1})) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + keys = tbl_17_ + end + local value = str1(compiler.compile1(ast[#ast], scope, parent, {nval = 1})) + local fmtstr = nil + if needs_separator_3f(root0, get_prev_line(parent)) then + fmtstr = "do end %s[%s] = %s" + else + fmtstr = "%s[%s] = %s" + end + return compiler.emit(parent, fmtstr:format(root0, table.concat(keys, "]["), value), ast) + end + doc_special("tset", {"tbl", "key1", "...", "keyN", "val"}, "Set the value of a table field. Deprecated in favor of set.") + local function calculate_if_target(scope, opts) + if not (opts.tail or opts.target or opts.nval) then + return "iife", true, nil + elseif (opts.nval and (opts.nval ~= 0) and not opts.target) then + local accum = {} + local target_exprs = {} + for i = 1, opts.nval do + local s = compiler.gensym(scope) + accum[i] = s + target_exprs[i] = utils.expr(s, "sym") + end + return "target", opts.tail, table.concat(accum, ", "), target_exprs + else + return "none", opts.tail, opts.target + end + end + local function if_2a(ast, scope, parent, opts) + compiler.assert((2 < #ast), "expected condition and body", ast) + if ((1 == (#ast % 2)) and (ast[(#ast - 1)] == true)) then + table.remove(ast, (#ast - 1)) + end + if (1 == (#ast % 2)) then + table.insert(ast, utils.sym("nil")) + end + if (#ast == 2) then + return SPECIALS["do"](utils.list(utils.sym("do"), ast[2]), scope, parent, opts) + else + local do_scope = compiler["make-scope"](scope) + local branches = {} + local wrapper, inner_tail, inner_target, target_exprs = calculate_if_target(scope, opts) + local body_opts = {nval = opts.nval, tail = inner_tail, target = inner_target} + local function compile_body(i) + local chunk = {} + local cscope = compiler["make-scope"](do_scope) + compiler["keep-side-effects"](compiler.compile1(ast[i], cscope, chunk, body_opts), chunk, nil, ast[i]) + return {chunk = chunk, scope = cscope} + end + for i = 2, (#ast - 1), 2 do + local condchunk = {} + local _560_ = compiler.compile1(ast[i], do_scope, condchunk, {nval = 1}) + local cond = _560_[1] + local branch = compile_body((i + 1)) + branch.cond = cond + branch.condchunk = condchunk + branch.nested = ((i ~= 2) and (next(condchunk, nil) == nil)) + table.insert(branches, branch) + end + local else_branch = compile_body(#ast) + local s = compiler.gensym(scope) + local buffer = {} + local last_buffer = buffer + for i = 1, #branches do + local branch = branches[i] + local fstr = nil + if not branch.nested then + fstr = "if %s then" + else + fstr = "elseif %s then" + end + local cond = tostring(branch.cond) + local cond_line = fstr:format(cond) + if branch.nested then + compiler.emit(last_buffer, branch.condchunk, ast) + else + for _, v in ipairs(branch.condchunk) do + compiler.emit(last_buffer, v, ast) + end + end + compiler.emit(last_buffer, cond_line, ast) + compiler.emit(last_buffer, branch.chunk, ast) + if (i == #branches) then + compiler.emit(last_buffer, "else", ast) + compiler.emit(last_buffer, else_branch.chunk, ast) + compiler.emit(last_buffer, "end", ast) + elseif not branches[(i + 1)].nested then + local next_buffer = {} + compiler.emit(last_buffer, "else", ast) + compiler.emit(last_buffer, next_buffer, ast) + compiler.emit(last_buffer, "end", ast) + last_buffer = next_buffer + end + end + if (wrapper == "iife") then + local iifeargs = ((scope.vararg and "...") or "") + compiler.emit(parent, ("local function %s(%s)"):format(tostring(s), iifeargs), ast) + compiler.emit(parent, buffer, ast) + compiler.emit(parent, "end", ast) + return utils.expr(("%s(%s)"):format(tostring(s), iifeargs), "statement") + elseif (wrapper == "none") then + for i = 1, #buffer do + compiler.emit(parent, buffer[i], ast) + end + return {returned = true} + else + compiler.emit(parent, ("local %s"):format(inner_target), ast) + for i = 1, #buffer do + compiler.emit(parent, buffer[i], ast) + end + return target_exprs + end + end + end + SPECIALS["if"] = if_2a + doc_special("if", {"cond1", "body1", "...", "condN", "bodyN"}, "Conditional form.\nTakes any number of condition/body pairs and evaluates the first body where\nthe condition evaluates to truthy. Similar to cond in other lisps.") + local function clause_3f(v) + return (utils["string?"](v) or (utils["sym?"](v) and not utils["multi-sym?"](v) and tostring(v):match("^&(.+)"))) + end + local function remove_until_condition(bindings, ast) + local _until = nil + for i = (#bindings - 1), 3, -1 do + local _566_0 = clause_3f(bindings[i]) + if ((_566_0 == false) or (_566_0 == nil)) then + elseif (nil ~= _566_0) then + local clause = _566_0 + compiler.assert(((clause == "until") and not _until), ("unexpected iterator clause: " .. clause), ast) + table.remove(bindings, i) + _until = table.remove(bindings, i) + end + end + return _until + end + local function compile_until(_3fcondition, scope, chunk) + if _3fcondition then + local _568_ = compiler.compile1(_3fcondition, scope, chunk, {nval = 1}) + local condition_lua = _568_[1] + return compiler.emit(chunk, ("if %s then break end"):format(tostring(condition_lua)), utils.expr(_3fcondition, "expression")) + end + end + local function iterator_bindings(ast) + local bindings = utils.copy(ast) + local _3funtil = remove_until_condition(bindings, ast) + local iter = table.remove(bindings) + local bindings0 = nil + if (1 == #bindings) then + bindings0 = (utils["list?"](bindings[1]) or bindings) + else + for _, b in ipairs(bindings) do + if utils["list?"](b) then + utils.warn("unexpected parens in iterator", b) + end + end + bindings0 = bindings + end + return bindings0, iter, _3funtil + end + SPECIALS.each = function(ast, scope, parent) + compiler.assert((3 <= #ast), "expected body expression", ast[1]) + compiler.assert(utils["table?"](ast[2]), "expected binding table", ast) + local sub_scope = compiler["make-scope"](scope) + local binding, iter, _3funtil_condition = iterator_bindings(ast[2]) + local destructures = {} + local deferred_scope_changes = {manglings = {}, symmeta = {}} + utils.hook("pre-each", ast, sub_scope, binding, iter, _3funtil_condition) + local function destructure_binding(v) + if utils["sym?"](v) then + return compiler["declare-local"](v, sub_scope, ast, nil, deferred_scope_changes) + else + local raw = utils.sym(compiler.gensym(sub_scope)) + destructures[raw] = v + return compiler["declare-local"](raw, sub_scope, ast) + end + end + local bind_vars = nil + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for _, b in ipairs(binding) do + local val_19_ = destructure_binding(b) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + bind_vars = tbl_17_ + end + local vals = compiler.compile1(iter, scope, parent) + local val_names = nil + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for _, v in ipairs(vals) do + local val_19_ = tostring(v) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + val_names = tbl_17_ + end + local chunk = {} + compiler.assert(bind_vars[1], "expected binding and iterator", ast) + compiler.emit(parent, ("for %s in %s do"):format(table.concat(bind_vars, ", "), table.concat(val_names, ", ")), ast) + for raw, args in utils.stablepairs(destructures) do + compiler.destructure(args, raw, ast, sub_scope, chunk, {declaration = true, nomulti = true, symtype = "each"}) + end + compiler["apply-deferred-scope-changes"](sub_scope, deferred_scope_changes, ast) + compile_until(_3funtil_condition, sub_scope, chunk) + compile_do(ast, sub_scope, chunk, 3) + compiler.emit(parent, chunk, ast) + return compiler.emit(parent, "end", ast) + end + doc_special("each", {"[key value (iterator)]", "..."}, "Runs the body once for each set of values provided by the given iterator.\nMost commonly used with ipairs for sequential tables or pairs for undefined\norder, but can be used with any iterator.", true) + local function while_2a(ast, scope, parent) + local len1 = #parent + local condition = compiler.compile1(ast[2], scope, parent, {nval = 1})[1] + local len2 = #parent + local sub_chunk = {} + if (len1 ~= len2) then + for i = (len1 + 1), len2 do + table.insert(sub_chunk, parent[i]) + parent[i] = nil + end + compiler.emit(parent, "while true do", ast) + compiler.emit(sub_chunk, ("if not %s then break end"):format(condition[1]), ast) + else + compiler.emit(parent, ("while " .. tostring(condition) .. " do"), ast) + end + compile_do(ast, compiler["make-scope"](scope), sub_chunk, 3) + compiler.emit(parent, sub_chunk, ast) + return compiler.emit(parent, "end", ast) + end + SPECIALS["while"] = while_2a + doc_special("while", {"condition", "..."}, "The classic while loop. Evaluates body until a condition is non-truthy.", true) + local function for_2a(ast, scope, parent) + compiler.assert(utils["table?"](ast[2]), "expected binding table", ast) + local ranges = setmetatable(utils.copy(ast[2]), getmetatable(ast[2])) + local until_condition = remove_until_condition(ranges, ast) + local binding_sym = table.remove(ranges, 1) + local sub_scope = compiler["make-scope"](scope) + local range_args = {} + local chunk = {} + compiler.assert(utils["sym?"](binding_sym), ("unable to bind %s %s"):format(type(binding_sym), tostring(binding_sym)), ast[2]) + compiler.assert((3 <= #ast), "expected body expression", ast[1]) + compiler.assert((#ranges <= 3), "unexpected arguments", ranges) + compiler.assert((1 < #ranges), "expected range to include start and stop", ranges) + utils.hook("pre-for", ast, sub_scope, binding_sym) + for i = 1, math.min(#ranges, 3) do + range_args[i] = str1(compiler.compile1(ranges[i], scope, parent, {nval = 1})) + end + compiler.emit(parent, ("for %s = %s do"):format(compiler["declare-local"](binding_sym, sub_scope, ast), table.concat(range_args, ", ")), ast) + compile_until(until_condition, sub_scope, chunk) + compile_do(ast, sub_scope, chunk, 3) + compiler.emit(parent, chunk, ast) + return compiler.emit(parent, "end", ast) + end + SPECIALS["for"] = for_2a + doc_special("for", {"[index start stop step?]", "..."}, "Numeric loop construct.\nEvaluates body once for each value between start and stop (inclusive).", true) + local function method_special_type(ast) + if (utils["string?"](ast[3]) and utils["valid-lua-identifier?"](ast[3])) then + return "native" + elseif utils["sym?"](ast[2]) then + return "nonnative" + else + return "binding" + end + end + local function native_method_call(ast, _scope, _parent, target, args) + local _577_ = ast + local _ = _577_[1] + local _0 = _577_[2] + local method_string = _577_[3] + local call_string = nil + if ((target.type == "literal") or (target.type == "varg") or ((target.type == "expression") and not (target[1]):match("[%)%]]$") and not (target[1]):match("%.[%a_][%w_]*$"))) then + call_string = "(%s):%s(%s)" + else + call_string = "%s:%s(%s)" + end + return utils.expr(string.format(call_string, tostring(target), method_string, table.concat(args, ", ")), "statement") + end + local function nonnative_method_call(ast, scope, parent, target, args) + local method_string = str1(compiler.compile1(ast[3], scope, parent, {nval = 1})) + local args0 = {tostring(target), unpack(args)} + return utils.expr(string.format("%s[%s](%s)", tostring(target), method_string, table.concat(args0, ", ")), "statement") + end + local function binding_method_call(ast, scope, parent, target, args) + local method_string = str1(compiler.compile1(ast[3], scope, parent, {nval = 1})) + local target_local = compiler.gensym(scope, "tgt") + local args0 = {target_local, unpack(args)} + compiler.emit(parent, string.format("local %s = %s", target_local, tostring(target))) + return utils.expr(string.format("(%s)[%s](%s)", target_local, method_string, table.concat(args0, ", ")), "statement") + end + local function method_call(ast, scope, parent) + compiler.assert((2 < #ast), "expected at least 2 arguments", ast) + local _579_ = compiler.compile1(ast[2], scope, parent, {nval = 1}) + local target = _579_[1] + local args = {} + for i = 4, #ast do + local subexprs = nil + local _580_ + if (i ~= #ast) then + _580_ = 1 + else + _580_ = nil + end + subexprs = compiler.compile1(ast[i], scope, parent, {nval = _580_}) + local tbl_17_ = args + local i_18_ = #tbl_17_ + for _, subexpr in ipairs(subexprs) do + local val_19_ = tostring(subexpr) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + end + local _583_0 = method_special_type(ast) + if (_583_0 == "native") then + return native_method_call(ast, scope, parent, target, args) + elseif (_583_0 == "nonnative") then + return nonnative_method_call(ast, scope, parent, target, args) + elseif (_583_0 == "binding") then + return binding_method_call(ast, scope, parent, target, args) + end + end + SPECIALS[":"] = method_call + doc_special(":", {"tbl", "method-name", "..."}, "Call the named method on tbl with the provided args.\nMethod name doesn't have to be known at compile-time; if it is, use\n(tbl:method-name ...) instead.") + SPECIALS.comment = function(ast, _, parent) + local c = nil + local _585_ + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for i, elt in ipairs(ast) do + local val_19_ = nil + if (i ~= 1) then + val_19_ = view(elt, {["one-line?"] = true}) + else + val_19_ = nil + end + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + _585_ = tbl_17_ + end + c = table.concat(_585_, " "):gsub("%]%]", "]\\]") + return compiler.emit(parent, ("--[[ " .. c .. " ]]"), ast) + end + doc_special("comment", {"..."}, "Comment which will be emitted in Lua output.", true) + local function hashfn_max_used(f_scope, i, max) + local max0 = nil + if f_scope.symmeta[("$" .. i)].used then + max0 = i + else + max0 = max + end + if (i < 9) then + return hashfn_max_used(f_scope, (i + 1), max0) + else + return max0 + end + end + SPECIALS.hashfn = function(ast, scope, parent) + compiler.assert((#ast == 2), "expected one argument", ast) + local f_scope = nil + do + local _590_0 = compiler["make-scope"](scope) + _590_0["vararg"] = false + _590_0["hashfn"] = true + f_scope = _590_0 + end + local f_chunk = {} + local name = compiler.gensym(scope) + local symbol = utils.sym(name) + local args = {} + compiler["declare-local"](symbol, scope, ast) + for i = 1, 9 do + args[i] = compiler["declare-local"](utils.sym(("$" .. i)), f_scope, ast) + end + local function walker(idx, node, _3fparent_node) + if utils["sym?"](node, "$...") then + f_scope.vararg = true + if _3fparent_node then + _3fparent_node[idx] = utils.varg() + return nil + else + return utils.varg() + end + else + return ((utils["list?"](node) and (not _3fparent_node or not utils["sym?"](node[1], "hashfn"))) or utils["table?"](node)) + end + end + utils["walk-tree"](ast, walker) + compiler.compile1(ast[2], f_scope, f_chunk, {tail = true}) + local max_used = hashfn_max_used(f_scope, 1, 0) + if f_scope.vararg then + compiler.assert((max_used == 0), "$ and $... in hashfn are mutually exclusive", ast) + end + local arg_str = nil + if f_scope.vararg then + arg_str = tostring(utils.varg()) + else + arg_str = table.concat(args, ", ", 1, max_used) + end + compiler.emit(parent, string.format("local function %s(%s)", name, arg_str), ast) + compiler.emit(parent, f_chunk, ast) + compiler.emit(parent, "end", ast) + return utils.expr(name, "sym") + end + doc_special("hashfn", {"..."}, "Function literal shorthand; args are either $... OR $1, $2, etc.") + local function comparator_special_type(ast) + if (3 == #ast) then + return "native" + elseif utils["every?"]({unpack(ast, 3, (#ast - 1))}, utils["idempotent-expr?"]) then + return "idempotent" + else + return "binding" + end + end + local function short_circuit_safe_3f(x, scope) + if (("table" ~= type(x)) or utils["sym?"](x) or utils["varg?"](x)) then + return true + elseif utils["table?"](x) then + local ok = true + for k, v in pairs(x) do + if not ok then break end + ok = (short_circuit_safe_3f(v, scope) and short_circuit_safe_3f(k, scope)) + end + return ok + elseif utils["list?"](x) then + if utils["sym?"](x[1]) then + local _596_0 = str1(x) + if ((_596_0 == "fn") or (_596_0 == "hashfn") or (_596_0 == "let") or (_596_0 == "local") or (_596_0 == "var") or (_596_0 == "set") or (_596_0 == "tset") or (_596_0 == "if") or (_596_0 == "each") or (_596_0 == "for") or (_596_0 == "while") or (_596_0 == "do") or (_596_0 == "lua") or (_596_0 == "global")) then + return false + elseif (((_596_0 == "<") or (_596_0 == ">") or (_596_0 == "<=") or (_596_0 == ">=") or (_596_0 == "=") or (_596_0 == "not=") or (_596_0 == "~=")) and (comparator_special_type(x) == "binding")) then + return false + else + local function _597_() + return (1 ~= x[2]) + end + if ((_596_0 == "pick-values") and _597_()) then + return false + else + local function _598_() + local call = _596_0 + return scope.macros[call] + end + if ((nil ~= _596_0) and _598_()) then + local call = _596_0 + return false + else + local function _599_() + return (method_special_type(x) == "binding") + end + if ((_596_0 == ":") and _599_()) then + return false + else + local _ = _596_0 + local ok = true + for i = 2, #x do + if not ok then break end + ok = short_circuit_safe_3f(x[i], scope) + end + return ok + end + end + end + end + else + local ok = true + for _, v in ipairs(x) do + if not ok then break end + ok = short_circuit_safe_3f(v, scope) + end + return ok + end + end + end + local function operator_special_result(ast, zero_arity, unary_prefix, padded_op, operands) + local _603_0 = #operands + if (_603_0 == 0) then + if zero_arity then + return utils.expr(zero_arity, "literal") + else + return compiler.assert(false, "Expected more than 0 arguments", ast) + end + elseif (_603_0 == 1) then + if unary_prefix then + return ("(" .. unary_prefix .. padded_op .. operands[1] .. ")") + else + return operands[1] + end + else + local _ = _603_0 + return ("(" .. table.concat(operands, padded_op) .. ")") + end + end + local function emit_short_circuit_if(ast, scope, parent, name, subast, accumulator, expr_string, setter) + if (accumulator ~= expr_string) then + compiler.emit(parent, string.format(setter, accumulator, expr_string), ast) + end + local function _608_() + if (name == "and") then + return accumulator + else + return ("not " .. accumulator) + end + end + compiler.emit(parent, ("if %s then"):format(_608_()), subast) + do + local chunk = {} + compiler.compile1(subast, scope, chunk, {nval = 1, target = accumulator}) + compiler.emit(parent, chunk) + end + return compiler.emit(parent, "end") + end + local function operator_special(name, zero_arity, unary_prefix, ast, scope, parent) + compiler.assert(not ((#ast == 2) and utils["varg?"](ast[2])), "tried to use vararg with operator", ast) + local padded_op = (" " .. name .. " ") + local operands, accumulator = {} + if utils["call-of?"](ast[#ast], "values") then + utils.warn("multiple values in operators are deprecated", ast) + end + for subast in iter_args(ast) do + if ((nil ~= next(operands)) and ((name == "or") or (name == "and")) and not short_circuit_safe_3f(subast, scope)) then + local expr_string = table.concat(operands, padded_op) + local setter = nil + if accumulator then + setter = "%s = %s" + else + setter = "local %s = %s" + end + if not accumulator then + accumulator = compiler.gensym(scope, name) + end + emit_short_circuit_if(ast, scope, parent, name, subast, accumulator, expr_string, setter) + operands = {accumulator} + else + table.insert(operands, str1(compiler.compile1(subast, scope, parent, {nval = 1}))) + end + end + return operator_special_result(ast, zero_arity, unary_prefix, padded_op, operands) + end + local function define_arithmetic_special(name, zero_arity, unary_prefix, _3flua_name) + local _614_ + do + local _613_0 = (_3flua_name or name) + local function _615_(...) + return operator_special(_613_0, zero_arity, unary_prefix, ...) + end + _614_ = _615_ + end + SPECIALS[name] = _614_ + return doc_special(name, {"a", "b", "..."}, "Arithmetic operator; works the same as Lua but accepts more arguments.") + end + define_arithmetic_special("+", "0", "0") + define_arithmetic_special("..", "''") + define_arithmetic_special("^") + define_arithmetic_special("-", nil, "") + define_arithmetic_special("*", "1", "1") + define_arithmetic_special("%") + define_arithmetic_special("/", nil, "1") + define_arithmetic_special("//", nil, "1") + SPECIALS["or"] = function(ast, scope, parent) + return operator_special("or", "false", nil, ast, scope, parent) + end + SPECIALS["and"] = function(ast, scope, parent) + return operator_special("and", "true", nil, ast, scope, parent) + end + doc_special("and", {"a", "b", "..."}, "Boolean operator; works the same as Lua but accepts more arguments.") + doc_special("or", {"a", "b", "..."}, "Boolean operator; works the same as Lua but accepts more arguments.") + local function bitop_special(native_name, lib_name, zero_arity, unary_prefix, ast, scope, parent) + if (#ast == 1) then + return compiler.assert(zero_arity, "Expected more than 0 arguments.", ast) + else + local len = #ast + local operands = {} + local padded_native_name = (" " .. native_name .. " ") + local prefixed_lib_name = ("bit." .. lib_name) + for i = 2, len do + local subexprs = nil + local _616_ + if (i ~= len) then + _616_ = 1 + else + _616_ = nil + end + subexprs = compiler.compile1(ast[i], scope, parent, {nval = _616_}) + local tbl_17_ = operands + local i_18_ = #tbl_17_ + for _, s in ipairs(subexprs) do + local val_19_ = tostring(s) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + end + if (#operands == 1) then + if utils.root.options.useBitLib then + return (prefixed_lib_name .. "(" .. unary_prefix .. ", " .. operands[1] .. ")") + else + return ("(" .. unary_prefix .. padded_native_name .. operands[1] .. ")") + end + else + if utils.root.options.useBitLib then + return (prefixed_lib_name .. "(" .. table.concat(operands, ", ") .. ")") + else + return ("(" .. table.concat(operands, padded_native_name) .. ")") + end + end + end + end + local function define_bitop_special(name, zero_arity, unary_prefix, native) + local function _623_(...) + return bitop_special(native, name, zero_arity, unary_prefix, ...) + end + SPECIALS[name] = _623_ + return nil + end + define_bitop_special("lshift", nil, "1", "<<") + define_bitop_special("rshift", nil, "1", ">>") + define_bitop_special("band", "-1", "-1", "&") + define_bitop_special("bor", "0", "0", "|") + define_bitop_special("bxor", "0", "0", "~") + doc_special("lshift", {"x", "n"}, "Bitwise logical left shift of x by n bits.\nOnly works in Lua 5.3+ or LuaJIT with the --use-bit-lib flag.") + doc_special("rshift", {"x", "n"}, "Bitwise logical right shift of x by n bits.\nOnly works in Lua 5.3+ or LuaJIT with the --use-bit-lib flag.") + doc_special("band", {"x1", "x2", "..."}, "Bitwise AND of any number of arguments.\nOnly works in Lua 5.3+ or LuaJIT with the --use-bit-lib flag.") + doc_special("bor", {"x1", "x2", "..."}, "Bitwise OR of any number of arguments.\nOnly works in Lua 5.3+ or LuaJIT with the --use-bit-lib flag.") + doc_special("bxor", {"x1", "x2", "..."}, "Bitwise XOR of any number of arguments.\nOnly works in Lua 5.3+ or LuaJIT with the --use-bit-lib flag.") + SPECIALS.bnot = function(ast, scope, parent) + compiler.assert((#ast == 2), "expected one argument", ast) + local _624_ = compiler.compile1(ast[2], scope, parent, {nval = 1}) + local value = _624_[1] + if utils.root.options.useBitLib then + return ("bit.bnot(" .. tostring(value) .. ")") + else + return ("~(" .. tostring(value) .. ")") + end + end + doc_special("bnot", {"x"}, "Bitwise negation; only works in Lua 5.3+ or LuaJIT with the --use-bit-lib flag.") + doc_special("..", {"a", "b", "..."}, "String concatenation operator; works the same as Lua but accepts more arguments.") + local function native_comparator(op, _626_0, scope, parent) + local _627_ = _626_0 + local _ = _627_[1] + local lhs_ast = _627_[2] + local rhs_ast = _627_[3] + local _628_ = compiler.compile1(lhs_ast, scope, parent, {nval = 1}) + local lhs = _628_[1] + local _629_ = compiler.compile1(rhs_ast, scope, parent, {nval = 1}) + local rhs = _629_[1] + return string.format("(%s %s %s)", tostring(lhs), op, tostring(rhs)) + end + local function idempotent_comparator(op, chain_op, ast, scope, parent) + local vals = nil + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for i = 2, #ast do + local val_19_ = str1(compiler.compile1(ast[i], scope, parent, {nval = 1})) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + vals = tbl_17_ + end + local comparisons = nil + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for i = 1, (#vals - 1) do + local val_19_ = string.format("(%s %s %s)", vals[i], op, vals[(i + 1)]) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + comparisons = tbl_17_ + end + local chain = string.format(" %s ", (chain_op or "and")) + return ("(" .. table.concat(comparisons, chain) .. ")") + end + local function binding_comparator(op, chain_op, ast, scope, parent) + local binding_left = {} + local binding_right = {} + local vals = {} + local chain = string.format(" %s ", (chain_op or "and")) + for i = 2, #ast do + local compiled = str1(compiler.compile1(ast[i], scope, parent, {nval = 1})) + if (utils["idempotent-expr?"](ast[i]) or (i == 2) or (i == #ast)) then + table.insert(vals, compiled) + else + local my_sym = compiler.gensym(scope) + table.insert(binding_left, my_sym) + table.insert(binding_right, compiled) + table.insert(vals, my_sym) + end + end + compiler.emit(parent, string.format("local %s = %s", table.concat(binding_left, ", "), table.concat(binding_right, ", "), ast)) + local _633_ + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for i = 1, (#vals - 1) do + local val_19_ = string.format("(%s %s %s)", vals[i], op, vals[(i + 1)]) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + _633_ = tbl_17_ + end + return ("(" .. table.concat(_633_, chain) .. ")") + end + local function define_comparator_special(name, _3flua_op, _3fchain_op) + do + local op = (_3flua_op or name) + local function opfn(ast, scope, parent) + compiler.assert((2 < #ast), "expected at least two arguments", ast) + local _635_0 = comparator_special_type(ast) + if (_635_0 == "native") then + return native_comparator(op, ast, scope, parent) + elseif (_635_0 == "idempotent") then + return idempotent_comparator(op, _3fchain_op, ast, scope, parent) + elseif (_635_0 == "binding") then + return binding_comparator(op, _3fchain_op, ast, scope, parent) + else + local _ = _635_0 + return error("internal compiler error. please report this to the fennel devs.") + end + end + SPECIALS[name] = opfn + end + return doc_special(name, {"a", "b", "..."}, "Comparison operator; works the same as Lua but accepts more arguments.") + end + define_comparator_special(">") + define_comparator_special("<") + define_comparator_special(">=") + define_comparator_special("<=") + define_comparator_special("=", "==") + define_comparator_special("not=", "~=", "or") + local function define_unary_special(op, _3frealop) + local function opfn(ast, scope, parent) + compiler.assert((#ast == 2), "expected one argument", ast) + local tail = compiler.compile1(ast[2], scope, parent, {nval = 1}) + return ((_3frealop or op) .. str1(tail)) + end + SPECIALS[op] = opfn + return nil + end + define_unary_special("not", "not ") + doc_special("not", {"x"}, "Logical operator; works the same as Lua.") + define_unary_special("length", "#") + doc_special("length", {"x"}, "Returns the length of a table or string.") + SPECIALS["~="] = SPECIALS["not="] + SPECIALS["#"] = SPECIALS.length + local function compile_time_3f(scope) + return ((scope == compiler.scopes.compiler) or (scope.parent and compile_time_3f(scope.parent))) + end + SPECIALS.quote = function(ast, scope, parent) + compiler.assert((#ast == 2), "expected one argument", ast) + return compiler["do-quote"](ast[2], scope, parent, not compile_time_3f(scope)) + end + doc_special("quote", {"x"}, "Quasiquote the following form. Only works in macro/compiler scope.") + local macro_loaded = {} + local function safe_getmetatable(tbl) + local mt = getmetatable(tbl) + assert((mt ~= getmetatable("")), "Illegal metatable access!") + return mt + end + local safe_require = nil + local function safe_compiler_env() + local _638_ + do + local _637_0 = rawget(_G, "utf8") + if (nil ~= _637_0) then + _638_ = utils.copy(_637_0) + else + _638_ = _637_0 + end + end + return {_VERSION = _VERSION, assert = assert, bit = rawget(_G, "bit"), error = error, getmetatable = safe_getmetatable, ipairs = ipairs, math = utils.copy(math), next = next, pairs = utils.stablepairs, pcall = pcall, print = print, rawequal = rawequal, rawget = rawget, rawlen = rawget(_G, "rawlen"), rawset = rawset, require = safe_require, select = select, setmetatable = setmetatable, string = utils.copy(string), table = utils.copy(table), tonumber = tonumber, tostring = tostring, type = type, utf8 = _638_, xpcall = xpcall} + end + local function combined_mt_pairs(env) + local combined = {} + local _640_ = getmetatable(env) + local __index = _640_["__index"] + if ("table" == type(__index)) then + for k, v in pairs(__index) do + combined[k] = v + end + end + for k, v in next, env, nil do + combined[k] = v + end + return next, combined, nil + end + local function make_compiler_env(ast, scope, parent, _3fopts) + local provided = nil + do + local _642_0 = (_3fopts or utils.root.options) + if ((_G.type(_642_0) == "table") and (_642_0["compiler-env"] == "strict")) then + provided = safe_compiler_env() + elseif ((_G.type(_642_0) == "table") and (nil ~= _642_0.compilerEnv)) then + local compilerEnv = _642_0.compilerEnv + provided = compilerEnv + elseif ((_G.type(_642_0) == "table") and (nil ~= _642_0["compiler-env"])) then + local compiler_env = _642_0["compiler-env"] + provided = compiler_env + else + local _ = _642_0 + provided = safe_compiler_env() + end + end + local env = nil + local function _644_() + return compiler.scopes.macro + end + local function _645_(symbol) + compiler.assert(compiler.scopes.macro, "must call from macro", ast) + return compiler.scopes.macro.manglings[tostring(symbol)] + end + local function _646_(base) + return utils.sym(compiler.gensym((compiler.scopes.macro or scope), base)) + end + local function _647_(form) + compiler.assert(compiler.scopes.macro, "must call from macro", ast) + return compiler.macroexpand(form, compiler.scopes.macro) + end + env = {["assert-compile"] = compiler.assert, ["ast-source"] = utils["ast-source"], ["comment?"] = utils["comment?"], ["fennel-module-name"] = fennel_module_name, ["get-scope"] = _644_, ["in-scope?"] = _645_, ["list?"] = utils["list?"], ["macro-loaded"] = macro_loaded, ["multi-sym?"] = utils["multi-sym?"], ["sequence?"] = utils["sequence?"], ["sym?"] = utils["sym?"], ["table?"] = utils["table?"], ["varg?"] = utils["varg?"], _AST = ast, _CHUNK = parent, _IS_COMPILER = true, _SCOPE = scope, _SPECIALS = compiler.scopes.global.specials, _VARARG = utils.varg(), comment = utils.comment, gensym = _646_, list = utils.list, macroexpand = _647_, pack = pack, sequence = utils.sequence, sym = utils.sym, unpack = unpack, version = utils.version, view = view} + env._G = env + return setmetatable(env, {__index = provided, __newindex = provided, __pairs = combined_mt_pairs}) + end + local function _648_(...) + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for c in string.gmatch((package.config or ""), "([^\n]+)") do + local val_19_ = c + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + return tbl_17_ + end + local _650_ = _648_(...) + local dirsep = _650_[1] + local pathsep = _650_[2] + local pathmark = _650_[3] + local pkg_config = {dirsep = (dirsep or "/"), pathmark = (pathmark or "?"), pathsep = (pathsep or ";")} + local function escapepat(str) + return string.gsub(str, "[^%w]", "%%%1") + end + local function search_module(modulename, _3fpathstring) + local pathsepesc = escapepat(pkg_config.pathsep) + local pattern = ("([^%s]*)%s"):format(pathsepesc, pathsepesc) + local no_dot_module = modulename:gsub("%.", pkg_config.dirsep) + local fullpath = ((_3fpathstring or utils["fennel-module"].path) .. pkg_config.pathsep) + local function try_path(path) + local filename = path:gsub(escapepat(pkg_config.pathmark), no_dot_module) + local _651_0 = io.open(filename) + if (nil ~= _651_0) then + local file = _651_0 + file:close() + return filename + else + local _ = _651_0 + return nil, ("no file '" .. filename .. "'") + end + end + local function find_in_path(start, _3ftried_paths) + local _653_0 = fullpath:match(pattern, start) + if (nil ~= _653_0) then + local path = _653_0 + local _654_0, _655_0 = try_path(path) + if (nil ~= _654_0) then + local filename = _654_0 + return filename + elseif ((_654_0 == nil) and (nil ~= _655_0)) then + local error = _655_0 + local function _657_() + local _656_0 = (_3ftried_paths or {}) + table.insert(_656_0, error) + return _656_0 + end + return find_in_path((start + #path + 1), _657_()) + end + else + local _ = _653_0 + local function _659_() + local tried_paths = table.concat((_3ftried_paths or {}), "\n\9") + if (_VERSION < "Lua 5.4") then + return ("\n\9" .. tried_paths) + else + return tried_paths + end + end + return nil, _659_() + end + end + return find_in_path(1) + end + local function make_searcher(_3foptions) + local function _662_(module_name) + local opts = utils.copy(utils.root.options) + for k, v in pairs((_3foptions or {})) do + opts[k] = v + end + opts["module-name"] = module_name + local _663_0, _664_0 = search_module(module_name) + if (nil ~= _663_0) then + local filename = _663_0 + local function _665_(...) + return utils["fennel-module"].dofile(filename, opts, ...) + end + return _665_, filename + elseif ((_663_0 == nil) and (nil ~= _664_0)) then + local error = _664_0 + return error + end + end + return _662_ + end + local function dofile_with_searcher(fennel_macro_searcher, filename, opts, ...) + local searchers = (package.loaders or package.searchers or {}) + local _ = table.insert(searchers, 1, fennel_macro_searcher) + local m = utils["fennel-module"].dofile(filename, opts, ...) + table.remove(searchers, 1) + return m + end + local function fennel_macro_searcher(module_name) + local opts = nil + do + local _667_0 = utils.copy(utils.root.options) + _667_0["module-name"] = module_name + _667_0["env"] = "_COMPILER" + _667_0["requireAsInclude"] = false + _667_0["allowedGlobals"] = nil + opts = _667_0 + end + local _668_0 = search_module(module_name, utils["fennel-module"]["macro-path"]) + if (nil ~= _668_0) then + local filename = _668_0 + local _669_ + if (opts["compiler-env"] == _G) then + local function _670_(...) + return dofile_with_searcher(fennel_macro_searcher, filename, opts, ...) + end + _669_ = _670_ + else + local function _671_(...) + return utils["fennel-module"].dofile(filename, opts, ...) + end + _669_ = _671_ + end + return _669_, filename + end + end + local function lua_macro_searcher(module_name) + local _674_0 = search_module(module_name, package.path) + if (nil ~= _674_0) then + local filename = _674_0 + local code = nil + do + local f = io.open(filename) + local function close_handlers_10_(ok_11_, ...) + f:close() + if ok_11_ then + return ... + else + return error(..., 0) + end + end + local function _676_() + return assert(f:read("*a")) + end + code = close_handlers_10_(_G.xpcall(_676_, (package.loaded.fennel or debug).traceback)) + end + local chunk = load_code(code, make_compiler_env(), filename) + return chunk, filename + end + end + local macro_searchers = {fennel_macro_searcher, lua_macro_searcher} + local function search_macro_module(modname, n) + local _678_0 = macro_searchers[n] + if (nil ~= _678_0) then + local f = _678_0 + local _679_0, _680_0 = f(modname) + if ((nil ~= _679_0) and true) then + local loader = _679_0 + local _3ffilename = _680_0 + return loader, _3ffilename + else + local _ = _679_0 + return search_macro_module(modname, (n + 1)) + end + end + end + local function sandbox_fennel_module(modname) + if ((modname == "fennel.macros") or (package and package.loaded and ("table" == type(package.loaded[modname])) and (package.loaded[modname].metadata == compiler.metadata))) then + local function _683_(_, ...) + return (compiler.metadata):setall(...) + end + return {metadata = {setall = _683_}, view = view} + end + end + local function _685_(modname) + local function _686_() + local loader, filename = search_macro_module(modname, 1) + compiler.assert(loader, (modname .. " module not found.")) + macro_loaded[modname] = loader(modname, filename) + return macro_loaded[modname] + end + return (macro_loaded[modname] or sandbox_fennel_module(modname) or _686_()) + end + safe_require = _685_ + local function add_macros(macros_2a, ast, scope) + compiler.assert(utils["table?"](macros_2a), "expected macros to be table", ast) + for k, v in pairs(macros_2a) do + compiler.assert((type(v) == "function"), "expected each macro to be function", ast) + compiler["check-binding-valid"](utils.sym(k), scope, ast, {["macro?"] = true}) + scope.macros[k] = v + end + return nil + end + local function resolve_module_name(_687_0, _scope, _parent, opts) + local _688_ = _687_0 + local second = _688_[2] + local filename = _688_["filename"] + local filename0 = (filename or (utils["table?"](second) and second.filename)) + local module_name = utils.root.options["module-name"] + local modexpr = compiler.compile(second, opts) + local modname_chunk = load_code(modexpr) + return modname_chunk(module_name, filename0) + end + SPECIALS["require-macros"] = function(ast, scope, parent, _3freal_ast) + compiler.assert((#ast == 2), "Expected one module name argument", (_3freal_ast or ast)) + local modname = resolve_module_name(ast, scope, parent, {}) + compiler.assert(utils["string?"](modname), "module name must compile to string", (_3freal_ast or ast)) + if not macro_loaded[modname] then + local loader, filename = search_macro_module(modname, 1) + compiler.assert(loader, (modname .. " module not found."), ast) + macro_loaded[modname] = compiler.assert(utils["table?"](loader(modname, filename)), "expected macros to be table", (_3freal_ast or ast)) + end + if ("import-macros" == str1(ast)) then + return macro_loaded[modname] + else + return add_macros(macro_loaded[modname], ast, scope) + end + end + doc_special("require-macros", {"macro-module-name"}, "Load given module and use its contents as macro definitions in current scope.\nDeprecated.") + local function emit_included_fennel(src, path, opts, sub_chunk) + local subscope = compiler["make-scope"](utils.root.scope.parent) + local forms = {} + if utils.root.options.requireAsInclude then + subscope.specials.require = compiler["require-include"] + end + for _, val in parser.parser(parser["string-stream"](src), path) do + table.insert(forms, val) + end + for i = 1, #forms do + local subopts = nil + if (i == #forms) then + subopts = {tail = true} + else + subopts = {nval = 0} + end + utils["propagate-options"](opts, subopts) + compiler.compile1(forms[i], subscope, sub_chunk, subopts) + end + return nil + end + local function include_path(ast, opts, path, mod, fennel_3f) + utils.root.scope.includes[mod] = "fnl/loading" + local src = nil + do + local f = assert(io.open(path)) + local function close_handlers_10_(ok_11_, ...) + f:close() + if ok_11_ then + return ... + else + return error(..., 0) + end + end + local function _694_() + return assert(f:read("*all")):gsub("[\13\n]*$", "") + end + src = close_handlers_10_(_G.xpcall(_694_, (package.loaded.fennel or debug).traceback)) + end + local ret = utils.expr(("require(\"" .. mod .. "\")"), "statement") + local target = ("package.preload[%q]"):format(mod) + local preload_str = (target .. " = " .. target .. " or function(...)") + local temp_chunk, sub_chunk = {}, {} + compiler.emit(temp_chunk, preload_str, ast) + compiler.emit(temp_chunk, sub_chunk) + compiler.emit(temp_chunk, "end", ast) + for _, v in ipairs(temp_chunk) do + table.insert(utils.root.chunk, v) + end + if fennel_3f then + emit_included_fennel(src, path, opts, sub_chunk) + else + compiler.emit(sub_chunk, src, ast) + end + utils.root.scope.includes[mod] = ret + return ret + end + local function include_circular_fallback(mod, modexpr, fallback, ast) + if (utils.root.scope.includes[mod] == "fnl/loading") then + compiler.assert(fallback, "circular include detected", ast) + return fallback(modexpr) + end + end + SPECIALS.include = function(ast, scope, parent, opts) + compiler.assert((#ast == 2), "expected one argument", ast) + local modexpr = nil + do + local _697_0, _698_0 = pcall(resolve_module_name, ast, scope, parent, opts) + if ((_697_0 == true) and (nil ~= _698_0)) then + local modname = _698_0 + modexpr = utils.expr(string.format("%q", modname), "literal") + else + local _ = _697_0 + modexpr = compiler.compile1(ast[2], scope, parent, {nval = 1})[1] + end + end + if ((modexpr.type ~= "literal") or ((modexpr[1]):byte() ~= 34)) then + if opts.fallback then + return opts.fallback(modexpr) + else + return compiler.assert(false, "module name must be string literal", ast) + end + else + local mod = load_code(("return " .. modexpr[1]))() + local oldmod = utils.root.options["module-name"] + local _ = nil + utils.root.options["module-name"] = mod + _ = nil + local res = nil + local function _702_() + local _701_0 = search_module(mod) + if (nil ~= _701_0) then + local fennel_path = _701_0 + return include_path(ast, opts, fennel_path, mod, true) + else + local _0 = _701_0 + local lua_path = search_module(mod, package.path) + if lua_path then + return include_path(ast, opts, lua_path, mod, false) + elseif opts.fallback then + return opts.fallback(modexpr) + else + return compiler.assert(false, ("module not found " .. mod), ast) + end + end + end + res = ((utils["member?"](mod, (utils.root.options.skipInclude or {})) and opts.fallback(modexpr, true)) or include_circular_fallback(mod, modexpr, opts.fallback, ast) or utils.root.scope.includes[mod] or _702_()) + utils.root.options["module-name"] = oldmod + return res + end + end + doc_special("include", {"module-name-literal"}, "Like require but load the target module during compilation and embed it in the\nLua output. The module must be a string literal and resolvable at compile time.") + local function eval_compiler_2a(ast, scope, parent) + local env = make_compiler_env(ast, scope, parent) + local opts = utils.copy(utils.root.options) + opts.scope = compiler["make-scope"](compiler.scopes.compiler) + opts.allowedGlobals = current_global_names(env) + return assert(load_code(compiler.compile(ast, opts), wrap_env(env)))(opts["module-name"], ast.filename) + end + SPECIALS.macros = function(ast, scope, parent) + compiler.assert((#ast == 2), "Expected one table argument", ast) + local macro_tbl = eval_compiler_2a(ast[2], scope, parent) + compiler.assert(utils["table?"](macro_tbl), "Expected one table argument", ast) + return add_macros(macro_tbl, ast, scope) + end + doc_special("macros", {"{:macro-name-1 (fn [...] ...) ... :macro-name-N macro-body-N}"}, "Define all functions in the given table as macros local to the current scope.") + SPECIALS["tail!"] = function(ast, scope, parent, opts) + compiler.assert((#ast == 2), "Expected one argument", ast) + local call = utils["list?"](compiler.macroexpand(ast[2], scope)) + local callee = tostring((call and utils["sym?"](call[1]))) + compiler.assert((call and not scope.specials[callee]), "Expected a function call as argument", ast) + compiler.assert(opts.tail, "Must be in tail position", ast) + return compiler.compile1(call, scope, parent, opts) + end + doc_special("tail!", {"body"}, "Assert that the body being called is in tail position.") + SPECIALS["pick-values"] = function(ast, scope, parent) + local n = ast[2] + local vals = utils.list(utils.sym("values"), unpack(ast, 3)) + compiler.assert((("number" == type(n)) and (0 <= n) and (n == math.floor(n))), ("Expected n to be an integer >= 0, got " .. tostring(n))) + if (1 == n) then + local _706_ = compiler.compile1(vals, scope, parent, {nval = 1}) + local _707_ = _706_[1] + local expr = _707_[1] + return {("(" .. expr .. ")")} + elseif (0 == n) then + for i = 3, #ast do + compiler["keep-side-effects"](compiler.compile1(ast[i], scope, parent, {nval = 0}), parent, nil, ast[i]) + end + return {} + else + local syms = nil + do + local tbl_17_ = utils.list() + local i_18_ = #tbl_17_ + for _ = 1, n do + local val_19_ = utils.sym(compiler.gensym(scope, "pv")) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + syms = tbl_17_ + end + compiler.destructure(syms, vals, ast, scope, parent, {declaration = true, nomulti = true, noundef = true, symtype = "pv"}) + return syms + end + end + doc_special("pick-values", {"n", "..."}, "Evaluate to exactly n values.\n\nFor example,\n (pick-values 2 ...)\nexpands to\n (let [(_0_ _1_) ...]\n (values _0_ _1_))") + SPECIALS["eval-compiler"] = function(ast, scope, parent) + local old_first = ast[1] + ast[1] = utils.sym("do") + local val = eval_compiler_2a(ast, scope, parent) + ast[1] = old_first + return val + end + doc_special("eval-compiler", {"..."}, "Evaluate the body at compile-time. Use the macro system instead if possible.", true) + SPECIALS.unquote = function(ast) + return compiler.assert(false, "tried to use unquote outside quote", ast) + end + doc_special("unquote", {"..."}, "Evaluate the argument even if it's in a quoted form.") + return {["current-global-names"] = current_global_names, ["get-function-metadata"] = get_function_metadata, ["load-code"] = load_code, ["macro-loaded"] = macro_loaded, ["macro-searchers"] = macro_searchers, ["make-compiler-env"] = make_compiler_env, ["make-searcher"] = make_searcher, ["search-module"] = search_module, ["wrap-env"] = wrap_env, doc = doc_2a} +end +package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or function(...) + local _281_ = require("fennel.utils") + local utils = _281_ + local unpack = _281_["unpack"] + local parser = require("fennel.parser") + local friend = require("fennel.friend") + local view = require("fennel.view") + local scopes = {compiler = nil, global = nil, macro = nil} + local function make_scope(_3fparent) + local parent = (_3fparent or scopes.global) + local _282_ + if parent then + _282_ = ((parent.depth or 0) + 1) + else + _282_ = 0 + end + return {["gensym-base"] = setmetatable({}, {__index = (parent and parent["gensym-base"])}), autogensyms = setmetatable({}, {__index = (parent and parent.autogensyms)}), depth = _282_, gensyms = setmetatable({}, {__index = (parent and parent.gensyms)}), hashfn = (parent and parent.hashfn), includes = setmetatable({}, {__index = (parent and parent.includes)}), macros = setmetatable({}, {__index = (parent and parent.macros)}), manglings = setmetatable({}, {__index = (parent and parent.manglings)}), parent = parent, refedglobals = {}, specials = setmetatable({}, {__index = (parent and parent.specials)}), symmeta = setmetatable({}, {__index = (parent and parent.symmeta)}), unmanglings = setmetatable({}, {__index = (parent and parent.unmanglings)}), vararg = (parent and parent.vararg)} + end + local function assert_msg(ast, msg) + local ast_tbl = nil + if ("table" == type(ast)) then + ast_tbl = ast + else + ast_tbl = {} + end + local m = getmetatable(ast) + local filename = ((m and m.filename) or ast_tbl.filename or "unknown") + local line = ((m and m.line) or ast_tbl.line or "?") + local col = ((m and m.col) or ast_tbl.col or "?") + local target = tostring((utils["sym?"](ast_tbl[1]) or ast_tbl[1] or "()")) + return string.format("%s:%s:%s: Compile error in '%s': %s", filename, line, col, target, msg) + end + local function assert_compile(condition, msg, ast, _3ffallback_ast) + if not condition then + local _285_ = (utils.root.options or {}) + local error_pinpoint = _285_["error-pinpoint"] + local source = _285_["source"] + local unfriendly = _285_["unfriendly"] + local ast0 = nil + if next(utils["ast-source"](ast)) then + ast0 = ast + else + ast0 = (_3ffallback_ast or {}) + end + if (nil == utils.hook("assert-compile", condition, msg, ast0, utils.root.reset)) then + utils.root.reset() + if unfriendly then + error(assert_msg(ast0, msg), 0) + else + friend["assert-compile"](condition, msg, ast0, source, {["error-pinpoint"] = error_pinpoint}) + end + end + end + return condition + end + scopes.global = make_scope() + scopes.global.vararg = true + scopes.compiler = make_scope(scopes.global) + scopes.macro = scopes.global + local serialize_subst_digits = {["\\10"] = "\\n", ["\\11"] = "\\v", ["\\12"] = "\\f", ["\\13"] = "\\r", ["\\7"] = "\\a", ["\\8"] = "\\b", ["\\9"] = "\\t"} + local function serialize_string(str) + local function _290_(_241) + return ("\\" .. _241:byte()) + end + return string.gsub(string.gsub(string.gsub(string.format("%q", str), "\\\n", "\\n"), "\\..?", serialize_subst_digits), "[\128-\255]", _290_) + end + local function global_mangling(str) + if utils["valid-lua-identifier?"](str) then + return str + else + local _292_ + do + local _291_0 = utils.root.options + if (nil ~= _291_0) then + _291_0 = _291_0["global-mangle"] + end + _292_ = _291_0 + end + if (_292_ == false) then + return ("_G[%q]"):format(str) + else + local function _294_(_241) + return string.format("_%02x", _241:byte()) + end + return ("__fnl_global__" .. str:gsub("[^%w]", _294_)) + end + end + end + local function global_unmangling(identifier) + local _296_0 = string.match(identifier, "^__fnl_global__(.*)$") + if (nil ~= _296_0) then + local rest = _296_0 + local _297_0 = nil + local function _298_(_241) + return string.char(tonumber(_241:sub(2), 16)) + end + _297_0 = rest:gsub("_[%da-f][%da-f]", _298_) + return _297_0 + else + local _ = _296_0 + return identifier + end + end + local function global_allowed_3f(name) + local allowed = nil + do + local _300_0 = utils.root.options + if (nil ~= _300_0) then + _300_0 = _300_0.allowedGlobals + end + allowed = _300_0 + end + return (not allowed or utils["member?"](name, allowed)) + end + local function unique_mangling(original, mangling, scope, append) + if scope.unmanglings[mangling] then + return unique_mangling(original, (original .. append), scope, (append + 1)) + else + return mangling + end + end + local function apply_deferred_scope_changes(scope, deferred_scope_changes, ast) + for raw, mangled in pairs(deferred_scope_changes.manglings) do + assert_compile(not scope.refedglobals[mangled], ("use of global " .. raw .. " is aliased by a local"), ast) + scope.manglings[raw] = mangled + end + for raw, symmeta in pairs(deferred_scope_changes.symmeta) do + scope.symmeta[raw] = symmeta + end + return nil + end + local function combine_parts(parts, scope) + local ret = (scope.manglings[parts[1]] or global_mangling(parts[1])) + for i = 2, #parts do + if utils["valid-lua-identifier?"](parts[i]) then + if (parts["multi-sym-method-call"] and (i == #parts)) then + ret = (ret .. ":" .. parts[i]) + else + ret = (ret .. "." .. parts[i]) + end + else + ret = (ret .. "[" .. serialize_string(parts[i]) .. "]") + end + end + return ret + end + local function root_scope(scope) + return ((utils.root and utils.root.scope) or (scope.parent and root_scope(scope.parent)) or scope) + end + local function next_append(root_scope_2a) + root_scope_2a["gensym-append"] = ((root_scope_2a["gensym-append"] or 0) + 1) + return ("_" .. root_scope_2a["gensym-append"] .. "_") + end + local function gensym(scope, _3fbase, _3fsuffix) + local root_scope_2a = root_scope(scope) + local mangling = ((_3fbase or "") .. next_append(root_scope_2a) .. (_3fsuffix or "")) + while scope.unmanglings[mangling] do + mangling = ((_3fbase or "") .. next_append(root_scope_2a) .. (_3fsuffix or "")) + end + if (_3fbase and (0 < #_3fbase)) then + scope["gensym-base"][mangling] = _3fbase + end + scope.gensyms[mangling] = true + return mangling + end + local function combine_auto_gensym(parts, first) + parts[1] = first + local last = table.remove(parts) + local last2 = table.remove(parts) + local last_joiner = ((parts["multi-sym-method-call"] and ":") or ".") + table.insert(parts, (last2 .. last_joiner .. last)) + return table.concat(parts, ".") + end + local function autogensym(base, scope) + local _306_0 = utils["multi-sym?"](base) + if (nil ~= _306_0) then + local parts = _306_0 + return combine_auto_gensym(parts, autogensym(parts[1], scope)) + else + local _ = _306_0 + local function _307_() + local mangling = gensym(scope, base:sub(1, -2), "auto") + scope.autogensyms[base] = mangling + return mangling + end + return (scope.autogensyms[base] or _307_()) + end + end + local function check_binding_valid(symbol, scope, ast, _3fopts) + local name = tostring(symbol) + local macro_3f = nil + do + local _309_0 = _3fopts + if (nil ~= _309_0) then + _309_0 = _309_0["macro?"] + end + macro_3f = _309_0 + end + assert_compile(("&" ~= name:match("[&.:]")), "invalid character: &", symbol) + assert_compile(not name:find("^%."), "invalid character: .", symbol) + assert_compile(not (scope.specials[name] or (not macro_3f and scope.macros[name])), ("local %s was overshadowed by a special form or macro"):format(name), ast) + return assert_compile(not utils["quoted?"](symbol), string.format("macro tried to bind %s without gensym", name), symbol) + end + local function declare_local(symbol, scope, ast, _3fvar_3f, _3fdeferred_scope_changes) + check_binding_valid(symbol, scope, ast) + assert_compile(not utils["multi-sym?"](symbol), ("unexpected multi symbol " .. tostring(symbol)), ast) + local str = tostring(symbol) + local raw = nil + if (utils["lua-keyword?"](str) or str:match("^%d")) then + raw = ("_" .. str) + else + raw = str + end + local mangling = nil + local function _312_(_241) + return string.format("_%02x", _241:byte()) + end + mangling = string.gsub(string.gsub(raw, "-", "_"), "[^%w_]", _312_) + local unique = unique_mangling(mangling, mangling, scope, 0) + scope.unmanglings[unique] = (scope["gensym-base"][str] or str) + do + local target = (_3fdeferred_scope_changes or scope) + target.manglings[str] = unique + target.symmeta[str] = {symbol = symbol, var = _3fvar_3f} + end + return unique + end + local function hashfn_arg_name(name, multi_sym_parts, scope) + if not scope.hashfn then + return nil + elseif (name == "$") then + return "$1" + elseif multi_sym_parts then + if (multi_sym_parts and (multi_sym_parts[1] == "$")) then + multi_sym_parts[1] = "$1" + end + return table.concat(multi_sym_parts, ".") + end + end + local function symbol_to_expression(symbol, scope, _3freference_3f) + utils.hook("symbol-to-expression", symbol, scope, _3freference_3f) + local name = symbol[1] + local multi_sym_parts = utils["multi-sym?"](name) + local name0 = (hashfn_arg_name(name, multi_sym_parts, scope) or name) + local parts = (multi_sym_parts or {name0}) + local etype = (((1 < #parts) and "expression") or "sym") + local local_3f = scope.manglings[parts[1]] + if (local_3f and scope.symmeta[parts[1]]) then + scope.symmeta[parts[1]]["used"] = true + symbol.referent = scope.symmeta[parts[1]].symbol + end + assert_compile(not scope.macros[parts[1]], "tried to reference a macro without calling it", symbol) + assert_compile((not scope.specials[parts[1]] or ("require" == parts[1])), "tried to reference a special form without calling it", symbol) + assert_compile((not _3freference_3f or local_3f or ("_ENV" == parts[1]) or global_allowed_3f(parts[1])), ("unknown identifier: " .. tostring(parts[1])), symbol) + local function _317_() + local _316_0 = utils.root.options + if (nil ~= _316_0) then + _316_0 = _316_0.allowedGlobals + end + return _316_0 + end + if (_317_() and not local_3f and scope.parent) then + scope.parent.refedglobals[parts[1]] = true + end + return utils.expr(combine_parts(parts, scope), etype) + end + local function emit(chunk, out, _3fast) + if (type(out) == "table") then + return table.insert(chunk, out) + else + return table.insert(chunk, {ast = _3fast, leaf = out}) + end + end + local function peephole(chunk) + if chunk.leaf then + return chunk + elseif ((3 <= #chunk) and (chunk[(#chunk - 2)].leaf == "do") and not chunk[(#chunk - 1)].leaf and (chunk[#chunk].leaf == "end")) then + local kid = peephole(chunk[(#chunk - 1)]) + local new_chunk = {ast = chunk.ast} + for i = 1, (#chunk - 3) do + table.insert(new_chunk, peephole(chunk[i])) + end + for i = 1, #kid do + table.insert(new_chunk, kid[i]) + end + return new_chunk + else + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for _, x in ipairs(chunk) do + local val_19_ = peephole(x) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + return tbl_17_ + end + end + local function flatten_chunk_correlated(main_chunk, options) + local function flatten(chunk, out, last_line, file) + local last_line0 = last_line + if chunk.leaf then + out[last_line0] = ((out[last_line0] or "") .. " " .. chunk.leaf) + else + for _, subchunk in ipairs(chunk) do + if (subchunk.leaf or next(subchunk)) then + local source = utils["ast-source"](subchunk.ast) + if (file == source.filename) then + last_line0 = math.max(last_line0, (source.line or 0)) + end + last_line0 = flatten(subchunk, out, last_line0, file) + end + end + end + return last_line0 + end + local out = {} + local last = flatten(main_chunk, out, 1, options.filename) + for i = 1, last do + if (out[i] == nil) then + out[i] = "" + end + end + return table.concat(out, "\n") + end + local function flatten_chunk(file_sourcemap, chunk, tab, depth) + if chunk.leaf then + local _327_ = utils["ast-source"](chunk.ast) + local endline = _327_["endline"] + local filename = _327_["filename"] + local line = _327_["line"] + if ("end" == chunk.leaf) then + table.insert(file_sourcemap, {filename, (endline or line)}) + else + table.insert(file_sourcemap, {filename, line}) + end + return chunk.leaf + else + local tab0 = nil + do + local _329_0 = tab + if (_329_0 == true) then + tab0 = " " + elseif (_329_0 == false) then + tab0 = "" + elseif (nil ~= _329_0) then + local tab1 = _329_0 + tab0 = tab1 + elseif (_329_0 == nil) then + tab0 = "" + else + tab0 = nil + end + end + local _331_ + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for _, c in ipairs(chunk) do + local val_19_ = nil + if (c.leaf or next(c)) then + local sub = flatten_chunk(file_sourcemap, c, tab0, (depth + 1)) + if (0 < depth) then + val_19_ = (tab0 .. sub:gsub("\n", ("\n" .. tab0))) + else + val_19_ = sub + end + else + val_19_ = nil + end + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + _331_ = tbl_17_ + end + return table.concat(_331_, "\n") + end + end + local sourcemap = {} + local function make_short_src(source) + local source0 = source:gsub("\n", " ") + if (#source0 <= 49) then + return ("[fennel \"" .. source0 .. "\"]") + else + return ("[fennel \"" .. source0:sub(1, 46) .. "...\"]") + end + end + local function flatten(chunk, options) + local chunk0 = peephole(chunk) + local indent = (options.indent or " ") + if options.correlate then + return flatten_chunk_correlated(chunk0, options), {} + else + local file_sourcemap = {} + local src = flatten_chunk(file_sourcemap, chunk0, indent, 0) + file_sourcemap.short_src = (options.filename or make_short_src((options.source or src))) + if options.filename then + file_sourcemap.key = ("@" .. options.filename) + else + file_sourcemap.key = src + end + sourcemap[file_sourcemap.key] = file_sourcemap + return src, file_sourcemap + end + end + local function make_metadata() + local function _339_(self, tgt, _3fkey) + if self[tgt] then + if (nil ~= _3fkey) then + return self[tgt][_3fkey] + else + return self[tgt] + end + end + end + local function _342_(self, tgt, key, value) + self[tgt] = (self[tgt] or {}) + self[tgt][key] = value + return tgt + end + local function _343_(self, tgt, ...) + local kv_len = select("#", ...) + local kvs = {...} + if ((kv_len % 2) ~= 0) then + error("metadata:setall() expected even number of k/v pairs") + end + self[tgt] = (self[tgt] or {}) + for i = 1, kv_len, 2 do + self[tgt][kvs[i]] = kvs[(i + 1)] + end + return tgt + end + return setmetatable({}, {__index = {get = _339_, set = _342_, setall = _343_}, __mode = "k"}) + end + local function exprs1(exprs) + local _345_ + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for _, e in ipairs(exprs) do + local val_19_ = tostring(e) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + _345_ = tbl_17_ + end + return table.concat(_345_, ", ") + end + local function keep_side_effects(exprs, chunk, _3fstart, ast) + for j = (_3fstart or 1), #exprs do + local subexp = exprs[j] + if ((subexp.type == "expression") and (subexp[1] ~= "nil")) then + emit(chunk, ("do local _ = %s end"):format(tostring(subexp)), ast) + elseif (subexp.type == "statement") then + local code = tostring(subexp) + local disambiguated = nil + if (code:byte() == 40) then + disambiguated = ("do end " .. code) + else + disambiguated = code + end + emit(chunk, disambiguated, ast) + end + end + return nil + end + local function handle_compile_opts(exprs, parent, opts, ast) + if opts.nval then + local n = opts.nval + local len = #exprs + if (n ~= len) then + if (n < len) then + keep_side_effects(exprs, parent, (n + 1), ast) + for i = (n + 1), len do + exprs[i] = nil + end + else + for i = (#exprs + 1), n do + exprs[i] = utils.expr("nil", "literal") + end + end + end + end + if opts.tail then + emit(parent, string.format("return %s", exprs1(exprs)), ast) + end + if opts.target then + local result = exprs1(exprs) + local function _353_() + if (result == "") then + return "nil" + else + return result + end + end + emit(parent, string.format("%s = %s", opts.target, _353_()), ast) + end + if (opts.tail or opts.target) then + return {returned = true} + else + exprs["returned"] = true + return exprs + end + end + local function find_macro(ast, scope) + local macro_2a = nil + do + local _356_0 = utils["sym?"](ast[1]) + if (_356_0 ~= nil) then + local _357_0 = tostring(_356_0) + if (_357_0 ~= nil) then + macro_2a = scope.macros[_357_0] + else + macro_2a = _357_0 + end + else + macro_2a = _356_0 + end + end + local multi_sym_parts = utils["multi-sym?"](ast[1]) + if (not macro_2a and multi_sym_parts) then + local nested_macro = utils["get-in"](scope.macros, multi_sym_parts) + assert_compile((not scope.macros[multi_sym_parts[1]] or (type(nested_macro) == "function")), "macro not found in imported macro module", ast) + return nested_macro + else + return macro_2a + end + end + local function propagate_trace_info(_361_0, _index, node) + local _362_ = _361_0 + local byteend = _362_["byteend"] + local bytestart = _362_["bytestart"] + local filename = _362_["filename"] + local line = _362_["line"] + do + local src = utils["ast-source"](node) + if (("table" == type(node)) and (filename ~= src.filename)) then + src.filename, src.line, src["from-macro?"] = filename, line, true + src.bytestart, src.byteend = bytestart, byteend + end + end + return ("table" == type(node)) + end + local function quote_literal_nils(index, node, parent) + if (parent and utils["list?"](parent)) then + for i = 1, utils.maxn(parent) do + if (nil == parent[i]) then + parent[i] = utils.sym("nil") + end + end + end + return index, node, parent + end + local function built_in_3f(m) + local found_3f = false + for _, f in pairs(scopes.global.macros) do + if found_3f then break end + found_3f = (f == m) + end + return found_3f + end + local function macroexpand_2a(ast, scope, _3fonce) + local _366_0 = nil + if utils["list?"](ast) then + _366_0 = find_macro(ast, scope) + else + _366_0 = nil + end + if (_366_0 == false) then + return ast + elseif (nil ~= _366_0) then + local macro_2a = _366_0 + local old_scope = scopes.macro + local _ = nil + scopes.macro = scope + _ = nil + local ok, transformed = nil, nil + local function _368_() + return macro_2a(unpack(ast, 2)) + end + local function _369_() + if built_in_3f(macro_2a) then + return tostring + else + return debug.traceback + end + end + ok, transformed = xpcall(_368_, _369_()) + local function _370_(...) + return propagate_trace_info(ast, quote_literal_nils(...)) + end + utils["walk-tree"](transformed, _370_) + scopes.macro = old_scope + assert_compile(ok, transformed, ast) + utils.hook("macroexpand", ast, transformed, scope) + if (_3fonce or not transformed) then + return transformed + else + return macroexpand_2a(transformed, scope) + end + else + local _ = _366_0 + return ast + end + end + local function compile_special(ast, scope, parent, opts, special) + local exprs = (special(ast, scope, parent, opts) or utils.expr("nil", "literal")) + local exprs0 = nil + if ("table" ~= type(exprs)) then + exprs0 = utils.expr(exprs, "expression") + else + exprs0 = exprs + end + local exprs2 = nil + if utils["expr?"](exprs0) then + exprs2 = {exprs0} + else + exprs2 = exprs0 + end + if not exprs2.returned then + return handle_compile_opts(exprs2, parent, opts, ast) + elseif (opts.tail or opts.target) then + return {returned = true} + else + return exprs2 + end + end + local function callable_3f(_376_0, ctype, callee) + local _377_ = _376_0 + local call_ast = _377_[1] + if ("literal" == ctype) then + return ("\"" == string.sub(callee, 1, 1)) + else + return (utils["sym?"](call_ast) or utils["list?"](call_ast)) + end + end + local function compile_function_call(ast, scope, parent, opts, compile1, len) + local _379_ = compile1(ast[1], scope, parent, {nval = 1})[1] + local callee = _379_[1] + local ctype = _379_["type"] + local fargs = {} + assert_compile(callable_3f(ast, ctype, callee), ("cannot call literal value " .. tostring(ast[1])), ast) + for i = 2, len do + local subexprs = nil + local _380_ + if (i ~= len) then + _380_ = 1 + else + _380_ = nil + end + subexprs = compile1(ast[i], scope, parent, {nval = _380_}) + table.insert(fargs, subexprs[1]) + if (i == len) then + for j = 2, #subexprs do + table.insert(fargs, subexprs[j]) + end + else + keep_side_effects(subexprs, parent, 2, ast[i]) + end + end + local pat = nil + if ("literal" == ctype) then + pat = "(%s)(%s)" + else + pat = "%s(%s)" + end + local call = string.format(pat, tostring(callee), exprs1(fargs)) + return handle_compile_opts({utils.expr(call, "statement")}, parent, opts, ast) + end + local function compile_call(ast, scope, parent, opts, compile1) + utils.hook("call", ast, scope) + local len = #ast + local first = ast[1] + local multi_sym_parts = utils["multi-sym?"](first) + local special = (utils["sym?"](first) and scope.specials[tostring(first)]) + assert_compile((0 < len), "expected a function, macro, or special to call", ast) + if special then + return compile_special(ast, scope, parent, opts, special) + elseif (multi_sym_parts and multi_sym_parts["multi-sym-method-call"]) then + local table_with_method = table.concat({unpack(multi_sym_parts, 1, (#multi_sym_parts - 1))}, ".") + local method_to_call = multi_sym_parts[#multi_sym_parts] + local new_ast = utils.list(utils.sym(":", ast), utils.sym(table_with_method, ast), method_to_call, select(2, unpack(ast))) + return compile1(new_ast, scope, parent, opts) + else + return compile_function_call(ast, scope, parent, opts, compile1, len) + end + end + local function compile_varg(ast, scope, parent, opts) + local _385_ + if scope.hashfn then + _385_ = "use $... in hashfn" + else + _385_ = "unexpected vararg" + end + assert_compile(scope.vararg, _385_, ast) + return handle_compile_opts({utils.expr("...", "varg")}, parent, opts, ast) + end + local function compile_sym(ast, scope, parent, opts) + local multi_sym_parts = utils["multi-sym?"](ast) + assert_compile(not (multi_sym_parts and multi_sym_parts["multi-sym-method-call"]), "multisym method calls may only be in call position", ast) + local e = nil + if (ast[1] == "nil") then + e = utils.expr("nil", "literal") + else + e = symbol_to_expression(ast, scope, true) + end + return handle_compile_opts({e}, parent, opts, ast) + end + local view_opts = nil + do + local nan = tostring((0 / 0)) + local _388_ + if (45 == nan:byte()) then + _388_ = "(0/0)" + else + _388_ = "(- (0/0))" + end + local _390_ + if (45 == nan:byte()) then + _390_ = "(- (0/0))" + else + _390_ = "(0/0)" + end + view_opts = {["negative-infinity"] = "(-1/0)", ["negative-nan"] = _388_, infinity = "(1/0)", nan = _390_} + end + local function compile_scalar(ast, _scope, parent, opts) + local compiled = nil + do + local _392_0 = type(ast) + if (_392_0 == "nil") then + compiled = "nil" + elseif (_392_0 == "boolean") then + compiled = tostring(ast) + elseif (_392_0 == "string") then + compiled = serialize_string(ast) + elseif (_392_0 == "number") then + compiled = view(ast, view_opts) + else + compiled = nil + end + end + return handle_compile_opts({utils.expr(compiled, "literal")}, parent, opts) + end + local function compile_table(ast, scope, parent, opts, compile1) + local function escape_key(k) + if ((type(k) == "string") and utils["valid-lua-identifier?"](k)) then + return k + else + local _394_ = compile1(k, scope, parent, {nval = 1}) + local compiled = _394_[1] + return ("[" .. tostring(compiled) .. "]") + end + end + local keys = {} + local buffer = nil + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for i, elem in ipairs(ast) do + local val_19_ = nil + do + local nval = ((nil ~= ast[(i + 1)]) and 1) + keys[i] = true + val_19_ = exprs1(compile1(elem, scope, parent, {nval = nval})) + end + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + buffer = tbl_17_ + end + do + local tbl_17_ = buffer + local i_18_ = #tbl_17_ + for k in utils.stablepairs(ast) do + local val_19_ = nil + if not keys[k] then + local _397_ = compile1(ast[k], scope, parent, {nval = 1}) + local v = _397_[1] + val_19_ = string.format("%s = %s", escape_key(k), tostring(v)) + else + val_19_ = nil + end + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + end + return handle_compile_opts({utils.expr(("{" .. table.concat(buffer, ", ") .. "}"), "expression")}, parent, opts, ast) + end + local function compile1(ast, scope, parent, _3fopts) + local opts = (_3fopts or {}) + local ast0 = macroexpand_2a(ast, scope) + if utils["list?"](ast0) then + return compile_call(ast0, scope, parent, opts, compile1) + elseif utils["varg?"](ast0) then + return compile_varg(ast0, scope, parent, opts) + elseif utils["sym?"](ast0) then + return compile_sym(ast0, scope, parent, opts) + elseif (type(ast0) == "table") then + return compile_table(ast0, scope, parent, opts, compile1) + elseif ((type(ast0) == "nil") or (type(ast0) == "boolean") or (type(ast0) == "number") or (type(ast0) == "string")) then + return compile_scalar(ast0, scope, parent, opts) + else + return assert_compile(false, ("could not compile value of type " .. type(ast0)), ast0) + end + end + local function destructure(to, from, ast, scope, parent, opts) + local opts0 = (opts or {}) + local _401_ = opts0 + local declaration = _401_["declaration"] + local forceglobal = _401_["forceglobal"] + local forceset = _401_["forceset"] + local isvar = _401_["isvar"] + local symtype = _401_["symtype"] + local symtype0 = ("_" .. (symtype or "dst")) + local setter = nil + if declaration then + setter = "local %s = %s" + else + setter = "%s = %s" + end + local deferred_scope_changes = {manglings = {}, symmeta = {}} + local function getname(symbol, ast0) + local raw = symbol[1] + assert_compile(not (opts0.nomulti and utils["multi-sym?"](raw)), ("unexpected multi symbol " .. raw), ast0) + if declaration then + return declare_local(symbol, scope, symbol, isvar, deferred_scope_changes) + else + local parts = (utils["multi-sym?"](raw) or {raw}) + local _403_ = parts + local first = _403_[1] + local meta = scope.symmeta[first] + assert_compile(not raw:find(":"), "cannot set method sym", symbol) + if ((#parts == 1) and not forceset) then + assert_compile(not (forceglobal and meta), string.format("global %s conflicts with local", tostring(symbol)), symbol) + assert_compile(not (meta and not meta.var), ("expected var " .. raw), symbol) + end + assert_compile((meta or not opts0.noundef or (scope.hashfn and ("$" == first)) or global_allowed_3f(first)), ("expected local " .. first), symbol) + if forceglobal then + assert_compile(not scope.symmeta[scope.unmanglings[raw]], ("global " .. raw .. " conflicts with local"), symbol) + scope.manglings[raw] = global_mangling(raw) + scope.unmanglings[global_mangling(raw)] = raw + local _406_ + do + local _405_0 = utils.root.options + if (nil ~= _405_0) then + _405_0 = _405_0.allowedGlobals + end + _406_ = _405_0 + end + if _406_ then + local _409_ + do + local _408_0 = utils.root.options + if (nil ~= _408_0) then + _408_0 = _408_0.allowedGlobals + end + _409_ = _408_0 + end + table.insert(_409_, raw) + end + end + return symbol_to_expression(symbol, scope)[1] + end + end + local function compile_top_target(lvalues) + local inits = nil + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for _, l in ipairs(lvalues) do + local val_19_ = nil + if scope.manglings[l] then + val_19_ = l + else + val_19_ = "nil" + end + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + inits = tbl_17_ + end + local init = table.concat(inits, ", ") + local lvalue = table.concat(lvalues, ", ") + local plast = parent[#parent] + local plen = #parent + local ret = compile1(from, scope, parent, {target = lvalue}) + if declaration then + for pi = plen, #parent do + if (parent[pi] == plast) then + plen = pi + end + end + if ((#parent == (plen + 1)) and parent[#parent].leaf) then + parent[#parent]["leaf"] = ("local " .. parent[#parent].leaf) + elseif (init == "nil") then + table.insert(parent, (plen + 1), {ast = ast, leaf = ("local " .. lvalue)}) + else + table.insert(parent, (plen + 1), {ast = ast, leaf = ("local " .. lvalue .. " = " .. init)}) + end + end + return ret + end + local function destructure_sym(left, rightexprs, up1, top_3f) + local lname = getname(left, up1) + check_binding_valid(left, scope, left) + if top_3f then + return compile_top_target({lname}) + else + return emit(parent, setter:format(lname, exprs1(rightexprs)), left) + end + end + local function dynamic_set_target(_420_0) + local _421_ = _420_0 + local _ = _421_[1] + local target = _421_[2] + local keys = {(table.unpack or unpack)(_421_, 3)} + assert_compile(utils["sym?"](target), "dynamic set needs symbol target", ast) + assert_compile(next(keys), "dynamic set needs at least one key", ast) + local keys0 = nil + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for _0, k in ipairs(keys) do + local val_19_ = tostring(compile1(k, scope, parent, {nval = 1})[1]) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + keys0 = tbl_17_ + end + return string.format("%s[%s]", tostring(symbol_to_expression(target, scope, true)), table.concat(keys0, "][")) + end + local function destructure_values(left, rightexprs, up1, destructure1, top_3f) + local left_names, tables = {}, {} + for i, name in ipairs(left) do + if utils["sym?"](name) then + table.insert(left_names, getname(name, up1)) + elseif utils["call-of?"](name, ".") then + table.insert(left_names, dynamic_set_target(name)) + else + local symname = gensym(scope, symtype0) + table.insert(left_names, symname) + tables[i] = {name, utils.expr(symname, "sym")} + end + end + assert_compile(left[1], "must provide at least one value", left) + if top_3f then + compile_top_target(left_names) + elseif utils["expr?"](rightexprs) then + emit(parent, setter:format(table.concat(left_names, ","), exprs1(rightexprs)), left) + else + local names = table.concat(left_names, ",") + local target = nil + if declaration then + target = ("local " .. names) + else + target = names + end + emit(parent, compile1(rightexprs, scope, parent, {target = target}), left) + end + for _, pair in utils.stablepairs(tables) do + destructure1(pair[1], {pair[2]}, left) + end + return nil + end + local unpack_fn = "function (t, k)\n return ((getmetatable(t) or {}).__fennelrest\n or function (t, k) return {(table.unpack or unpack)(t, k)} end)(t, k)\n end" + local unpack_ks = "function (t, e)\n local rest = {}\n for k, v in pairs(t) do\n if not e[k] then rest[k] = v end\n end\n return rest\n end" + local function destructure_kv_rest(s, v, left, excluded_keys, destructure1) + local exclude_str = nil + local _426_ + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for _, k in ipairs(excluded_keys) do + local val_19_ = string.format("[%s] = true", serialize_string(k)) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + _426_ = tbl_17_ + end + exclude_str = table.concat(_426_, ", ") + local subexpr = utils.expr(string.format(string.gsub(("(" .. unpack_ks .. ")(%s, {%s})"), "\n%s*", " "), s, exclude_str), "expression") + return destructure1(v, {subexpr}, left) + end + local function destructure_rest(s, k, left, destructure1) + local unpack_str = ("(" .. unpack_fn .. ")(%s, %s)") + local formatted = string.format(string.gsub(unpack_str, "\n%s*", " "), s, k) + local subexpr = utils.expr(formatted, "expression") + local function _428_() + local next_symbol = left[(k + 2)] + return ((nil == next_symbol) or utils["sym?"](next_symbol, "&as")) + end + assert_compile((utils["sequence?"](left) and _428_()), "expected rest argument before last parameter", left) + return destructure1(left[(k + 1)], {subexpr}, left) + end + local function optimize_table_destructure_3f(left, right) + local function _429_() + local all = next(left) + for _, d in ipairs(left) do + if not all then break end + all = ((utils["sym?"](d) and not tostring(d):find("^&")) or (utils["list?"](d) and utils["sym?"](d[1], "."))) + end + return all + end + return (utils["sequence?"](left) and utils["sequence?"](right) and _429_()) + end + local function destructure_table(left, rightexprs, top_3f, destructure1, up1) + assert_compile((("table" == type(rightexprs)) and not utils["sym?"](rightexprs, "nil")), "could not destructure literal", left) + if optimize_table_destructure_3f(left, rightexprs) then + return destructure_values(utils.list(unpack(left)), utils.list(utils.sym("values"), unpack(rightexprs)), up1, destructure1) + else + local right = nil + do + local _430_0 = nil + if top_3f then + _430_0 = exprs1(compile1(from, scope, parent)) + else + _430_0 = exprs1(rightexprs) + end + if (_430_0 == "") then + right = "nil" + elseif (nil ~= _430_0) then + local right0 = _430_0 + right = right0 + else + right = nil + end + end + local s = nil + if utils["sym?"](rightexprs) then + s = right + else + s = gensym(scope, symtype0) + end + local excluded_keys = {} + if not utils["sym?"](rightexprs) then + emit(parent, string.format("local %s = %s", s, right), left) + end + for k, v in utils.stablepairs(left) do + if not (("number" == type(k)) and tostring(left[(k - 1)]):find("^&")) then + if (utils["sym?"](k) and (tostring(k) == "&")) then + destructure_kv_rest(s, v, left, excluded_keys, destructure1) + elseif (utils["sym?"](v) and (tostring(v) == "&")) then + destructure_rest(s, k, left, destructure1) + elseif (utils["sym?"](k) and (tostring(k) == "&as")) then + destructure_sym(v, {utils.expr(tostring(s))}, left) + elseif (utils["sequence?"](left) and (tostring(v) == "&as")) then + local _, next_sym, trailing = select(k, unpack(left)) + assert_compile((nil == trailing), "expected &as argument before last parameter", left) + destructure_sym(next_sym, {utils.expr(tostring(s))}, left) + else + local key = nil + if (type(k) == "string") then + key = serialize_string(k) + else + key = k + end + local subexpr = utils.expr(("%s[%s]"):format(s, key), "expression") + if (type(k) == "string") then + table.insert(excluded_keys, k) + end + destructure1(v, subexpr, left) + end + end + end + return nil + end + end + local function destructure1(left, rightexprs, up1, top_3f) + if (utils["sym?"](left) and (left[1] ~= "nil")) then + destructure_sym(left, rightexprs, up1, top_3f) + elseif utils["table?"](left) then + destructure_table(left, rightexprs, top_3f, destructure1, up1) + elseif utils["call-of?"](left, ".") then + destructure_values({left}, rightexprs, up1, destructure1) + elseif utils["list?"](left) then + assert_compile(top_3f, "can't nest multi-value destructuring", left) + destructure_values(left, rightexprs, up1, destructure1, true) + else + assert_compile(false, string.format("unable to bind %s %s", type(left), tostring(left)), (((type(up1[2]) == "table") and up1[2]) or up1)) + end + return (top_3f and {returned = true}) + end + local ret = destructure1(to, from, ast, true) + utils.hook("destructure", from, to, scope, opts0) + apply_deferred_scope_changes(scope, deferred_scope_changes, ast) + return ret + end + local function require_include(ast, scope, parent, opts) + opts.fallback = function(e, no_warn) + if not no_warn then + utils.warn(("include module not found, falling back to require: %s"):format(tostring(e)), ast) + end + return utils.expr(string.format("require(%s)", tostring(e)), "statement") + end + return scopes.global.specials.include(ast, scope, parent, opts) + end + local function compile_asts(asts, options) + local opts = utils.copy(options) + local scope = nil + if ("_COMPILER" == opts.scope) then + scope = scopes.compiler + elseif opts.scope then + scope = opts.scope + else + scope = make_scope(scopes.global) + end + local chunk = {} + if opts.requireAsInclude then + scope.specials.require = require_include + end + if opts.assertAsRepl then + scope.macros.assert = scope.macros["assert-repl"] + end + local _445_ = utils.root + _445_["set-reset"](_445_) + utils.root.chunk, utils.root.scope, utils.root.options = chunk, scope, opts + for i = 1, #asts do + local exprs = compile1(asts[i], scope, chunk, {nval = (((i < #asts) and 0) or nil), tail = (i == #asts)}) + keep_side_effects(exprs, chunk, nil, asts[i]) + if (i == #asts) then + utils.hook("chunk", asts[i], scope) + end + end + utils.root.reset() + return flatten(chunk, opts) + end + local function compile_stream(stream, _3fopts) + local opts = (_3fopts or {}) + local asts = nil + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for _, ast in parser.parser(stream, opts.filename, opts) do + local val_19_ = ast + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + asts = tbl_17_ + end + return compile_asts(asts, opts) + end + local function compile_string(str, _3fopts) + return compile_stream(parser["string-stream"](str, _3fopts), _3fopts) + end + local function compile(from, _3fopts) + local _448_0 = type(from) + if (_448_0 == "userdata") then + local function _449_() + local _450_0 = from:read(1) + if (nil ~= _450_0) then + return _450_0:byte() + else + return _450_0 + end + end + return compile_stream(_449_, _3fopts) + elseif (_448_0 == "function") then + return compile_stream(from, _3fopts) + else + local _ = _448_0 + return compile_asts({from}, _3fopts) + end + end + local function traceback_frame(info) + if ((info.what == "C") and info.name) then + return string.format("\9[C]: in function '%s'", info.name) + elseif (info.what == "C") then + return "\9[C]: in ?" + else + local remap = sourcemap[info.source] + if (remap and remap[info.currentline]) then + if ((remap[info.currentline][1] or "unknown") ~= "unknown") then + info.short_src = sourcemap[("@" .. remap[info.currentline][1])].short_src + else + info.short_src = remap.short_src + end + info.currentline = (remap[info.currentline][2] or -1) + end + if (info.what == "Lua") then + local function _455_() + if info.name then + return ("'" .. info.name .. "'") + else + return "?" + end + end + return string.format("\9%s:%d: in function %s", info.short_src, info.currentline, _455_()) + elseif (info.short_src == "(tail call)") then + return " (tail call)" + else + return string.format("\9%s:%d: in main chunk", info.short_src, info.currentline) + end + end + end + local lua_getinfo = debug.getinfo + local function traceback(_3fmsg, _3fstart) + local _458_0 = type(_3fmsg) + if ((_458_0 == "nil") or (_458_0 == "string")) then + local msg = (_3fmsg or "") + if ((msg:find("^%g+:%d+:%d+ Compile error:.*") or msg:find("^%g+:%d+:%d+ Parse error:.*")) and not utils["debug-on?"]("trace")) then + return msg + else + local lines = {} + if (msg:find("^%g+:%d+:%d+ Compile error:") or msg:find("^%g+:%d+:%d+ Parse error:")) then + table.insert(lines, msg) + else + local newmsg = msg:gsub("^[^:]*:%d+:%s+", "runtime error: ") + table.insert(lines, newmsg) + end + table.insert(lines, "stack traceback:") + local done_3f, level = false, (_3fstart or 2) + while not done_3f do + do + local _460_0 = lua_getinfo(level, "Sln") + if (_460_0 == nil) then + done_3f = true + elseif (nil ~= _460_0) then + local info = _460_0 + table.insert(lines, traceback_frame(info)) + end + end + level = (level + 1) + end + return table.concat(lines, "\n") + end + else + local _ = _458_0 + return _3fmsg + end + end + local function getinfo(thread_or_level, ...) + local thread_or_level0 = nil + if ("number" == type(thread_or_level)) then + thread_or_level0 = (1 + thread_or_level) + else + thread_or_level0 = thread_or_level + end + local info = lua_getinfo(thread_or_level0, ...) + local mapped = (info and sourcemap[info.source]) + if mapped then + for _, key in ipairs({"currentline", "linedefined", "lastlinedefined"}) do + local mapped_value = nil + do + local _465_0 = mapped + if (nil ~= _465_0) then + _465_0 = _465_0[info[key]] + end + if (nil ~= _465_0) then + _465_0 = _465_0[2] + end + mapped_value = _465_0 + end + if (info[key] and mapped_value) then + info[key] = mapped_value + end + end + if info.activelines then + local tbl_14_ = {} + for line in pairs(info.activelines) do + local k_15_, v_16_ = mapped[line][2], true + if ((k_15_ ~= nil) and (v_16_ ~= nil)) then + tbl_14_[k_15_] = v_16_ + end + end + info.activelines = tbl_14_ + end + if (info.what == "Lua") then + info.what = "Fennel" + end + end + return info + end + local function mixed_concat(t, joiner) + local seen = {} + local ret, s = "", "" + for k, v in ipairs(t) do + table.insert(seen, k) + ret = (ret .. s .. v) + s = joiner + end + for k, v in utils.stablepairs(t) do + if not seen[k] then + ret = (ret .. s .. "[" .. k .. "]" .. "=" .. v) + s = joiner + end + end + return ret + end + local function do_quote(form, scope, parent, runtime_3f) + local function quote_all(form0, discard_non_numbers) + local tbl_14_ = {} + for k, v in utils.stablepairs(form0) do + local k_15_, v_16_ = nil, nil + if (type(k) == "number") then + k_15_, v_16_ = k, do_quote(v, scope, parent, runtime_3f) + elseif not discard_non_numbers then + k_15_, v_16_ = do_quote(k, scope, parent, runtime_3f), do_quote(v, scope, parent, runtime_3f) + else + k_15_, v_16_ = nil + end + if ((k_15_ ~= nil) and (v_16_ ~= nil)) then + tbl_14_[k_15_] = v_16_ + end + end + return tbl_14_ + end + if utils["varg?"](form) then + assert_compile(not runtime_3f, "quoted ... may only be used at compile time", form) + return "_VARARG" + elseif utils["sym?"](form) then + local filename = nil + if form.filename then + filename = string.format("%q", form.filename) + else + filename = "nil" + end + local symstr = tostring(form) + assert_compile(not runtime_3f, "symbols may only be used at compile time", form) + if (symstr:find("#$") or symstr:find("#[:.]")) then + return string.format("_G.sym('%s', {filename=%s, line=%s})", autogensym(symstr, scope), filename, (form.line or "nil")) + else + return string.format("_G.sym('%s', {quoted=true, filename=%s, line=%s})", symstr, filename, (form.line or "nil")) + end + elseif utils["call-of?"](form, "unquote") then + local res = unpack(compile1(form[2], scope, parent)) + return res[1] + elseif utils["list?"](form) then + local mapped = quote_all(form, true) + local filename = nil + if form.filename then + filename = string.format("%q", form.filename) + else + filename = "nil" + end + assert_compile(not runtime_3f, "lists may only be used at compile time", form) + return string.format(("setmetatable({filename=%s, line=%s, bytestart=%s, %s}" .. ", getmetatable(_G.list()))"), filename, (form.line or "nil"), (form.bytestart or "nil"), mixed_concat(mapped, ", ")) + elseif utils["sequence?"](form) then + local mapped_str = mixed_concat(quote_all(form), ", ") + local source = getmetatable(form) + local filename = nil + if source.filename then + filename = ("%q"):format(source.filename) + else + filename = "nil" + end + if runtime_3f then + return string.format("{%s}", mapped_str) + else + return string.format("setmetatable({%s}, {filename=%s, line=%s, sequence=%s})", mapped_str, filename, (source.line or "nil"), "(getmetatable(_G.sequence()))['sequence']") + end + elseif (type(form) == "table") then + local source = getmetatable(form) + local filename = nil + if source.filename then + filename = string.format("%q", source.filename) + else + filename = "nil" + end + local function _482_() + if source then + return source.line + else + return "nil" + end + end + return string.format("setmetatable({%s}, {filename=%s, line=%s})", mixed_concat(quote_all(form), ", "), filename, _482_()) + elseif (type(form) == "string") then + return serialize_string(form) + else + return tostring(form) + end + end + return {["apply-deferred-scope-changes"] = apply_deferred_scope_changes, ["check-binding-valid"] = check_binding_valid, ["compile-stream"] = compile_stream, ["compile-string"] = compile_string, ["declare-local"] = declare_local, ["do-quote"] = do_quote, ["global-allowed?"] = global_allowed_3f, ["global-mangling"] = global_mangling, ["global-unmangling"] = global_unmangling, ["keep-side-effects"] = keep_side_effects, ["make-scope"] = make_scope, ["require-include"] = require_include, ["symbol-to-expression"] = symbol_to_expression, assert = assert_compile, autogensym = autogensym, compile = compile, compile1 = compile1, destructure = destructure, emit = emit, gensym = gensym, getinfo = getinfo, macroexpand = macroexpand_2a, metadata = make_metadata(), scopes = scopes, sourcemap = sourcemap, traceback = traceback} +end +package.preload["fennel.friend"] = package.preload["fennel.friend"] or function(...) + local _193_ = require("fennel.utils") + local utils = _193_ + local unpack = _193_["unpack"] + local utf8_ok_3f, utf8 = pcall(require, "utf8") + local suggestions = {["$ and $... in hashfn are mutually exclusive"] = {"modifying the hashfn so it only contains $... or $, $1, $2, $3, etc"}, ["can't introduce (.*) here"] = {"declaring the local at the top-level"}, ["can't start multisym segment with a digit"] = {"removing the digit", "adding a non-digit before the digit"}, ["cannot call literal value"] = {"checking for typos", "checking for a missing function name", "making sure to use prefix operators, not infix"}, ["could not compile value of type "] = {"debugging the macro you're calling to return a list or table"}, ["could not read number (.*)"] = {"removing the non-digit character", "beginning the identifier with a non-digit if it is not meant to be a number"}, ["expected a function.* to call"] = {"removing the empty parentheses", "using square brackets if you want an empty table"}, ["expected at least one pattern/body pair"] = {"adding a pattern and a body to execute when the pattern matches"}, ["expected binding and iterator"] = {"making sure you haven't omitted a local name or iterator"}, ["expected binding sequence"] = {"placing a table here in square brackets containing identifiers to bind"}, ["expected body expression"] = {"putting some code in the body of this form after the bindings"}, ["expected each macro to be function"] = {"ensuring that the value for each key in your macros table contains a function", "avoid defining nested macro tables"}, ["expected even number of name/value bindings"] = {"finding where the identifier or value is missing"}, ["expected even number of pattern/body pairs"] = {"checking that every pattern has a body to go with it", "adding _ before the final body"}, ["expected even number of values in table literal"] = {"removing a key", "adding a value"}, ["expected local"] = {"looking for a typo", "looking for a local which is used out of its scope"}, ["expected macros to be table"] = {"ensuring your macro definitions return a table"}, ["expected parameters"] = {"adding function parameters as a list of identifiers in brackets"}, ["expected range to include start and stop"] = {"adding missing arguments"}, ["expected rest argument before last parameter"] = {"moving & to right before the final identifier when destructuring"}, ["expected symbol for function parameter: (.*)"] = {"changing %s to an identifier instead of a literal value"}, ["expected var (.*)"] = {"declaring %s using var instead of let/local", "introducing a new local instead of changing the value of %s"}, ["expected vararg as last parameter"] = {"moving the \"...\" to the end of the parameter list"}, ["expected whitespace before opening delimiter"] = {"adding whitespace"}, ["global (.*) conflicts with local"] = {"renaming local %s"}, ["invalid character: (.)"] = {"deleting or replacing %s", "avoiding reserved characters like \", \\, ', ~, ;, @, `, and comma"}, ["local (.*) was overshadowed by a special form or macro"] = {"renaming local %s"}, ["macro not found in macro module"] = {"checking the keys of the imported macro module's returned table"}, ["macro tried to bind (.*) without gensym"] = {"changing to %s# when introducing identifiers inside macros"}, ["malformed multisym"] = {"ensuring each period or colon is not followed by another period or colon"}, ["may only be used at compile time"] = {"moving this to inside a macro if you need to manipulate symbols/lists", "using square brackets instead of parens to construct a table"}, ["method must be last component"] = {"using a period instead of a colon for field access", "removing segments after the colon", "making the method call, then looking up the field on the result"}, ["mismatched closing delimiter (.), expected (.)"] = {"replacing %s with %s", "deleting %s", "adding matching opening delimiter earlier"}, ["missing subject"] = {"adding an item to operate on"}, ["multisym method calls may only be in call position"] = {"using a period instead of a colon to reference a table's fields", "putting parens around this"}, ["tried to reference a macro without calling it"] = {"renaming the macro so as not to conflict with locals"}, ["tried to reference a special form without calling it"] = {"making sure to use prefix operators, not infix", "wrapping the special in a function if you need it to be first class"}, ["tried to use unquote outside quote"] = {"moving the form to inside a quoted form", "removing the comma"}, ["tried to use vararg with operator"] = {"accumulating over the operands"}, ["unable to bind (.*)"] = {"replacing the %s with an identifier"}, ["unexpected arguments"] = {"removing an argument", "checking for typos"}, ["unexpected closing delimiter (.)"] = {"deleting %s", "adding matching opening delimiter earlier"}, ["unexpected iterator clause"] = {"removing an argument", "checking for typos"}, ["unexpected multi symbol (.*)"] = {"removing periods or colons from %s"}, ["unexpected vararg"] = {"putting \"...\" at the end of the fn parameters if the vararg was intended"}, ["unknown identifier: (.*)"] = {"looking to see if there's a typo", "using the _G table instead, eg. _G.%s if you really want a global", "moving this code to somewhere that %s is in scope", "binding %s as a local in the scope of this code"}, ["unused local (.*)"] = {"renaming the local to _%s if it is meant to be unused", "fixing a typo so %s is used", "disabling the linter which checks for unused locals"}, ["use of global (.*) is aliased by a local"] = {"renaming local %s", "refer to the global using _G.%s instead of directly"}} + local function suggest(msg) + local s = nil + for pat, sug in pairs(suggestions) do + if s then break end + local matches = {msg:match(pat)} + if next(matches) then + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for _, s0 in ipairs(sug) do + local val_19_ = s0:format(unpack(matches)) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + s = tbl_17_ + else + s = nil + end + end + return s + end + local function read_line(filename, line, _3fsource) + if _3fsource then + local matcher = string.gmatch((_3fsource .. "\n"), "(.-)(\13?\n)") + for _ = 2, line do + matcher() + end + return matcher() + else + local f = assert(_G.io.open(filename)) + local function close_handlers_10_(ok_11_, ...) + f:close() + if ok_11_ then + return ... + else + return error(..., 0) + end + end + local function _197_() + for _ = 2, line do + f:read() + end + return f:read() + end + return close_handlers_10_(_G.xpcall(_197_, (package.loaded.fennel or debug).traceback)) + end + end + local function sub(str, start, _end) + if ((_end < start) or (#str < start)) then + return "" + elseif utf8_ok_3f then + return string.sub(str, utf8.offset(str, start), ((utf8.offset(str, (_end + 1)) or (utf8.len(str) + 1)) - 1)) + else + return string.sub(str, start, math.min(_end, str:len())) + end + end + local function highlight_line(codeline, col, _3fendcol, opts) + if ((opts and (false == opts["error-pinpoint"])) or (os and os.getenv and os.getenv("NO_COLOR"))) then + return codeline + else + local _200_ = (opts or {}) + local error_pinpoint = _200_["error-pinpoint"] + local endcol = (_3fendcol or col) + local eol = nil + if utf8_ok_3f then + eol = utf8.len(codeline) + else + eol = string.len(codeline) + end + local _202_ = (error_pinpoint or {"\27[7m", "\27[0m"}) + local open = _202_[1] + local close = _202_[2] + return (sub(codeline, 1, col) .. open .. sub(codeline, (col + 1), (endcol + 1)) .. close .. sub(codeline, (endcol + 2), eol)) + end + end + local function friendly_msg(msg, _204_0, source, opts) + local _205_ = _204_0 + local col = _205_["col"] + local endcol = _205_["endcol"] + local endline = _205_["endline"] + local filename = _205_["filename"] + local line = _205_["line"] + local ok, codeline = pcall(read_line, filename, line, source) + local endcol0 = nil + if (ok and codeline and (line ~= endline)) then + endcol0 = #codeline + else + endcol0 = endcol + end + local out = {msg, ""} + if (ok and codeline) then + if col then + table.insert(out, highlight_line(codeline, col, endcol0, opts)) + else + table.insert(out, codeline) + end + end + for _, suggestion in ipairs((suggest(msg) or {})) do + table.insert(out, ("* Try %s."):format(suggestion)) + end + return table.concat(out, "\n") + end + local function assert_compile(condition, msg, ast, source, opts) + if not condition then + local _209_ = utils["ast-source"](ast) + local col = _209_["col"] + local filename = _209_["filename"] + local line = _209_["line"] + error(friendly_msg(("%s:%s:%s: Compile error: %s"):format((filename or "unknown"), (line or "?"), (col or "?"), msg), utils["ast-source"](ast), source, opts), 0) + end + return condition + end + local function parse_error(msg, filename, line, col, source, opts) + return error(friendly_msg(("%s:%s:%s: Parse error: %s"):format(filename, line, col, msg), {col = col, filename = filename, line = line}, source, opts), 0) + end + return {["assert-compile"] = assert_compile, ["parse-error"] = parse_error} +end +package.preload["fennel.parser"] = package.preload["fennel.parser"] or function(...) + local _192_ = require("fennel.utils") + local utils = _192_ + local unpack = _192_["unpack"] + local friend = require("fennel.friend") + local function granulate(getchunk) + local c, index, done_3f = "", 1, false + local function _211_(parser_state) + if not done_3f then + if (index <= #c) then + local b = c:byte(index) + index = (index + 1) + return b + else + local _212_0 = getchunk(parser_state) + if (nil ~= _212_0) then + local input = _212_0 + c, index = input, 2 + return c:byte() + else + local _ = _212_0 + done_3f = true + return nil + end + end + end + end + local function _216_() + c = "" + return nil + end + return _211_, _216_ + end + local function string_stream(str, _3foptions) + local str0 = str:gsub("^#!", ";;") + if _3foptions then + _3foptions.source = str0 + end + local index = 1 + local function _218_() + local r = str0:byte(index) + index = (index + 1) + return r + end + return _218_ + end + local delims = {[123] = 125, [125] = true, [40] = 41, [41] = true, [91] = 93, [93] = true} + local function sym_char_3f(b) + local b0 = nil + if ("number" == type(b)) then + b0 = b + else + b0 = string.byte(b) + end + return ((32 < b0) and not delims[b0] and (b0 ~= 127) and (b0 ~= 34) and (b0 ~= 39) and (b0 ~= 126) and (b0 ~= 59) and (b0 ~= 44) and (b0 ~= 64) and (b0 ~= 96)) + end + local prefixes = {[35] = "hashfn", [39] = "quote", [44] = "unquote", [96] = "quote"} + local nan, negative_nan = nil, nil + if (45 == string.byte(tostring((0 / 0)))) then + nan, negative_nan = ( - (0 / 0)), (0 / 0) + else + nan, negative_nan = (0 / 0), ( - (0 / 0)) + end + local function char_starter_3f(b) + return (((1 < b) and (b < 127)) or ((192 < b) and (b < 247))) + end + local function parser_fn(getbyte, filename, _221_0) + local _222_ = _221_0 + local options = _222_ + local comments = _222_["comments"] + local source = _222_["source"] + local unfriendly = _222_["unfriendly"] + local stack = {} + local line, byteindex, col, prev_col, lastb = 1, 0, 0, 0, nil + local function ungetb(ub) + if char_starter_3f(ub) then + col = (col - 1) + end + if (ub == 10) then + line, col = (line - 1), prev_col + end + byteindex = (byteindex - 1) + lastb = ub + return nil + end + local function getb() + local r = nil + if lastb then + r, lastb = lastb, nil + else + r = getbyte({["stack-size"] = #stack}) + end + if r then + byteindex = (byteindex + 1) + end + if (r and char_starter_3f(r)) then + col = (col + 1) + end + if (r == 10) then + line, col, prev_col = (line + 1), 0, col + end + return r + end + local function warn(...) + return (options.warn or utils.warn)(...) + end + local function whitespace_3f(b) + local function _230_() + local _229_0 = options.whitespace + if (nil ~= _229_0) then + _229_0 = _229_0[b] + end + return _229_0 + end + return ((b == 32) or ((9 <= b) and (b <= 13)) or _230_()) + end + local function parse_error(msg, _3fcol_adjust) + local col0 = (col + (_3fcol_adjust or -1)) + if (nil == utils["hook-opts"]("parse-error", options, msg, filename, (line or "?"), col0, source, utils.root.reset)) then + utils.root.reset() + if unfriendly then + return error(string.format("%s:%s:%s: Parse error: %s", filename, (line or "?"), col0, msg), 0) + else + return friend["parse-error"](msg, filename, (line or "?"), col0, source, options) + end + end + end + local function parse_stream() + local whitespace_since_dispatch, done_3f, retval = true + local function set_source_fields(source0) + source0.byteend, source0.endcol, source0.endline = byteindex, (col - 1), line + return nil + end + local function dispatch(v, _3fsource, _3fraw) + whitespace_since_dispatch = false + local v0 = nil + do + local _234_0 = utils["hook-opts"]("parse-form", options, v, _3fsource, _3fraw, stack) + if (nil ~= _234_0) then + local hookv = _234_0 + v0 = hookv + else + local _ = _234_0 + v0 = v + end + end + local _236_0 = stack[#stack] + if (_236_0 == nil) then + retval, done_3f = v0, true + return nil + elseif ((_G.type(_236_0) == "table") and (nil ~= _236_0.prefix)) then + local prefix = _236_0.prefix + local source0 = nil + do + local _237_0 = table.remove(stack) + set_source_fields(_237_0) + source0 = _237_0 + end + local list = utils.list(utils.sym(prefix, source0), v0) + return dispatch(utils.copy(source0, list)) + elseif (nil ~= _236_0) then + local top = _236_0 + return table.insert(top, v0) + end + end + local function badend() + local closers = nil + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for _, _239_0 in ipairs(stack) do + local _240_ = _239_0 + local closer = _240_["closer"] + local val_19_ = closer + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + closers = tbl_17_ + end + local _242_ + if (#stack == 1) then + _242_ = "" + else + _242_ = "s" + end + return parse_error(string.format("expected closing delimiter%s %s", _242_, string.char(unpack(closers))), 0) + end + local function skip_whitespace(b, close_table) + if (b and whitespace_3f(b)) then + whitespace_since_dispatch = true + return skip_whitespace(getb(), close_table) + elseif (not b and next(stack)) then + badend() + for i = #stack, 2, -1 do + close_table(stack[i].closer) + end + return stack[1].closer + else + return b + end + end + local function parse_comment(b, contents) + if (b and (10 ~= b)) then + local function _245_() + table.insert(contents, string.char(b)) + return contents + end + return parse_comment(getb(), _245_()) + elseif comments then + ungetb(10) + return dispatch(utils.comment(table.concat(contents), {filename = filename, line = line})) + end + end + local function open_table(b) + if not whitespace_since_dispatch then + parse_error(("expected whitespace before opening delimiter " .. string.char(b))) + end + return table.insert(stack, {bytestart = byteindex, closer = delims[b], col = (col - 1), filename = filename, line = line}) + end + local function close_list(list) + return dispatch(setmetatable(list, getmetatable(utils.list()))) + end + local function close_sequence(tbl) + local mt = getmetatable(utils.sequence()) + for k, v in pairs(tbl) do + if ("number" ~= type(k)) then + mt[k] = v + tbl[k] = nil + end + end + return dispatch(setmetatable(tbl, mt)) + end + local function add_comment_at(comments0, index, node) + local _249_0 = comments0[index] + if (nil ~= _249_0) then + local existing = _249_0 + return table.insert(existing, node) + else + local _ = _249_0 + comments0[index] = {node} + return nil + end + end + local function next_noncomment(tbl, i) + if utils["comment?"](tbl[i]) then + return next_noncomment(tbl, (i + 1)) + elseif utils["sym?"](tbl[i], ":") then + return tostring(tbl[(i + 1)]) + else + return tbl[i] + end + end + local function extract_comments(tbl) + local comments0 = {keys = {}, last = {}, values = {}} + while utils["comment?"](tbl[#tbl]) do + table.insert(comments0.last, 1, table.remove(tbl)) + end + local last_key_3f = false + for i, node in ipairs(tbl) do + if not utils["comment?"](node) then + last_key_3f = not last_key_3f + elseif last_key_3f then + add_comment_at(comments0.values, next_noncomment(tbl, i), node) + else + add_comment_at(comments0.keys, next_noncomment(tbl, i), node) + end + end + for i = #tbl, 1, -1 do + if utils["comment?"](tbl[i]) then + table.remove(tbl, i) + end + end + return comments0 + end + local function close_curly_table(tbl) + local comments0 = extract_comments(tbl) + local keys = {} + local val = {} + if ((#tbl % 2) ~= 0) then + byteindex = (byteindex - 1) + parse_error("expected even number of values in table literal") + end + setmetatable(val, tbl) + for i = 1, #tbl, 2 do + if ((tostring(tbl[i]) == ":") and utils["sym?"](tbl[(i + 1)]) and utils["sym?"](tbl[i])) then + tbl[i] = tostring(tbl[(i + 1)]) + end + val[tbl[i]] = tbl[(i + 1)] + table.insert(keys, tbl[i]) + end + tbl.comments = comments0 + tbl.keys = keys + return dispatch(val) + end + local function close_table(b) + local top = table.remove(stack) + if (top == nil) then + parse_error(("unexpected closing delimiter " .. string.char(b))) + end + if (top.closer and (top.closer ~= b)) then + parse_error(("mismatched closing delimiter " .. string.char(b) .. ", expected " .. string.char(top.closer))) + end + set_source_fields(top) + if (b == 41) then + return close_list(top) + elseif (b == 93) then + return close_sequence(top) + else + return close_curly_table(top) + end + end + local function parse_string_loop(chars, b, state) + if b then + table.insert(chars, string.char(b)) + end + local state0 = nil + do + local _260_0 = {state, b} + if ((_G.type(_260_0) == "table") and (_260_0[1] == "base") and (_260_0[2] == 92)) then + state0 = "backslash" + elseif ((_G.type(_260_0) == "table") and (_260_0[1] == "base") and (_260_0[2] == 34)) then + state0 = "done" + elseif ((_G.type(_260_0) == "table") and (_260_0[1] == "backslash") and (_260_0[2] == 10)) then + table.remove(chars, (#chars - 1)) + state0 = "base" + else + local _ = _260_0 + state0 = "base" + end + end + if (b and (state0 ~= "done")) then + return parse_string_loop(chars, getb(), state0) + else + return b + end + end + local function escape_char(c) + return ({[10] = "\\n", [11] = "\\v", [12] = "\\f", [13] = "\\r", [7] = "\\a", [8] = "\\b", [9] = "\\t"})[c:byte()] + end + local function parse_string(source0) + if not whitespace_since_dispatch then + warn("expected whitespace before string", nil, filename, line) + end + table.insert(stack, {closer = 34}) + local chars = {"\""} + if not parse_string_loop(chars, getb(), "base") then + badend() + end + table.remove(stack) + local raw = table.concat(chars) + local formatted = raw:gsub("[\7-\13]", escape_char) + local _265_0 = (rawget(_G, "loadstring") or load)(("return " .. formatted)) + if (nil ~= _265_0) then + local load_fn = _265_0 + return dispatch(load_fn(), source0, raw) + elseif (_265_0 == nil) then + return parse_error(("Invalid string: " .. raw)) + end + end + local function parse_prefix(b) + table.insert(stack, {bytestart = byteindex, col = (col - 1), filename = filename, line = line, prefix = prefixes[b]}) + local nextb = getb() + local trailing_whitespace_3f = (whitespace_3f(nextb) or (true == delims[nextb])) + if (trailing_whitespace_3f and (b ~= 35)) then + parse_error("invalid whitespace after quoting prefix") + end + ungetb(nextb) + if (trailing_whitespace_3f and (b == 35)) then + local source0 = table.remove(stack) + set_source_fields(source0) + return dispatch(utils.sym("#", source0)) + end + end + local function parse_sym_loop(chars, b) + if (b and sym_char_3f(b)) then + table.insert(chars, string.char(b)) + return parse_sym_loop(chars, getb()) + else + if b then + ungetb(b) + end + return chars + end + end + local function parse_number(rawstr, source0) + local trimmed = (not rawstr:find("^_") and rawstr:gsub("_", "")) + if ((trimmed == "nan") or (trimmed == "-nan")) then + return false + elseif rawstr:match("^%d") then + dispatch((tonumber(trimmed) or parse_error(("could not read number \"" .. rawstr .. "\""))), source0, rawstr) + return true + else + local _271_0 = tonumber(trimmed) + if (nil ~= _271_0) then + local x = _271_0 + dispatch(x, source0, rawstr) + return true + else + local _ = _271_0 + return false + end + end + end + local function check_malformed_sym(rawstr) + local function col_adjust(pat) + return (rawstr:find(pat) - utils.len(rawstr) - 1) + end + if (rawstr:match("^~") and (rawstr ~= "~=")) then + parse_error("invalid character: ~") + elseif (rawstr:match("[%.:][%.:]") and (rawstr ~= "..") and (rawstr ~= "$...")) then + parse_error(("malformed multisym: " .. rawstr), col_adjust("[%.:][%.:]")) + elseif ((rawstr ~= ":") and rawstr:match(":$")) then + parse_error(("malformed multisym: " .. rawstr), col_adjust(":$")) + elseif rawstr:match(":.+[%.:]") then + parse_error(("method must be last component of multisym: " .. rawstr), col_adjust(":.+[%.:]")) + end + if not whitespace_since_dispatch then + warn("expected whitespace before token", nil, filename, line) + end + return rawstr + end + local function parse_sym(b) + local source0 = {bytestart = byteindex, col = (col - 1), filename = filename, line = line} + local rawstr = table.concat(parse_sym_loop({string.char(b)}, getb())) + set_source_fields(source0) + if (rawstr == "true") then + return dispatch(true, source0) + elseif (rawstr == "false") then + return dispatch(false, source0) + elseif (rawstr == "...") then + return dispatch(utils.varg(source0)) + elseif (rawstr == ".inf") then + return dispatch((1 / 0), source0, rawstr) + elseif (rawstr == "-.inf") then + return dispatch((-1 / 0), source0, rawstr) + elseif (rawstr == ".nan") then + return dispatch(nan, source0, rawstr) + elseif (rawstr == "-.nan") then + return dispatch(negative_nan, source0, rawstr) + elseif rawstr:match("^:.+$") then + return dispatch(rawstr:sub(2), source0, rawstr) + elseif not parse_number(rawstr, source0) then + return dispatch(utils.sym(check_malformed_sym(rawstr), source0)) + end + end + local function parse_loop(b) + if not b then + elseif (b == 59) then + parse_comment(getb(), {";"}) + elseif (type(delims[b]) == "number") then + open_table(b) + elseif delims[b] then + close_table(b) + elseif (b == 34) then + parse_string({bytestart = byteindex, col = col, filename = filename, line = line}) + elseif prefixes[b] then + parse_prefix(b) + elseif (sym_char_3f(b) or (b == string.byte("~"))) then + parse_sym(b) + elseif not utils["hook-opts"]("illegal-char", options, b, getb, ungetb, dispatch) then + parse_error(("invalid character: " .. string.char(b))) + end + if not b then + return nil + elseif done_3f then + return true, retval + else + return parse_loop(skip_whitespace(getb(), close_table)) + end + end + return parse_loop(skip_whitespace(getb(), close_table)) + end + local function _279_() + stack, line, byteindex, col, lastb = {}, 1, 0, 0, ((lastb ~= 10) and lastb) + return nil + end + return parse_stream, _279_ + end + local function parser(stream_or_string, _3ffilename, _3foptions) + local filename = (_3ffilename or "unknown") + local options = (_3foptions or utils.root.options or {}) + assert(("string" == type(filename)), "expected filename as second argument to parser") + if ("string" == type(stream_or_string)) then + return parser_fn(string_stream(stream_or_string, options), filename, options) + else + return parser_fn(stream_or_string, filename, options) + end + end + return {["string-stream"] = string_stream, ["sym-char?"] = sym_char_3f, granulate = granulate, parser = parser} +end +local utils = nil +package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) + local type_order = {["function"] = 5, boolean = 2, number = 1, string = 3, table = 4, thread = 7, userdata = 6} + local default_opts = {["detect-cycles?"] = true, ["empty-as-sequence?"] = false, ["escape-newlines?"] = false, ["line-length"] = 80, ["max-sparse-gap"] = 1, ["metamethod?"] = true, ["one-line?"] = false, ["prefer-colon?"] = false, ["utf8?"] = true, depth = 128} + local lua_pairs = pairs + local lua_ipairs = ipairs + local function pairs(t) + local _1_0 = getmetatable(t) + if ((_G.type(_1_0) == "table") and (nil ~= _1_0.__pairs)) then + local p = _1_0.__pairs + return p(t) + else + local _ = _1_0 + return lua_pairs(t) + end + end + local function ipairs(t) + local _3_0 = getmetatable(t) + if ((_G.type(_3_0) == "table") and (nil ~= _3_0.__ipairs)) then + local i = _3_0.__ipairs + return i(t) + else + local _ = _3_0 + return lua_ipairs(t) + end + end + local function length_2a(t) + local _5_0 = getmetatable(t) + if ((_G.type(_5_0) == "table") and (nil ~= _5_0.__len)) then + local l = _5_0.__len + return l(t) + else + local _ = _5_0 + return #t + end + end + local function get_default(key) + local _7_0 = default_opts[key] + if (_7_0 == nil) then + return error(("option '%s' doesn't have a default value, use the :after key to set it"):format(tostring(key))) + elseif (nil ~= _7_0) then + local v = _7_0 + return v + end + end + local function getopt(options, key) + local _9_0 = options[key] + if ((_G.type(_9_0) == "table") and (nil ~= _9_0.once)) then + local val_2a = _9_0.once + return val_2a + else + local _3fval = _9_0 + return _3fval + end + end + local function normalize_opts(options) + local tbl_14_ = {} + for k, v in pairs(options) do + local k_15_, v_16_ = nil, nil + local function _12_() + local _11_0 = v + if ((_G.type(_11_0) == "table") and (nil ~= _11_0.after)) then + local val = _11_0.after + return val + else + local function _13_() + return v.once + end + if ((_G.type(_11_0) == "table") and _13_()) then + return get_default(k) + else + local _ = _11_0 + return v + end + end + end + k_15_, v_16_ = k, _12_() + if ((k_15_ ~= nil) and (v_16_ ~= nil)) then + tbl_14_[k_15_] = v_16_ + end + end + return tbl_14_ + end + local function sort_keys(_16_0, _18_0) + local _17_ = _16_0 + local a = _17_[1] + local _19_ = _18_0 + local b = _19_[1] + local ta = type(a) + local tb = type(b) + if ((ta == tb) and ((ta == "string") or (ta == "number"))) then + return (a < b) + else + local dta = type_order[ta] + local dtb = type_order[tb] + if (dta and dtb) then + return (dta < dtb) + elseif dta then + return true + elseif dtb then + return false + else + return (ta < tb) + end + end + end + local function max_index_gap(kv) + local gap = 0 + if (0 < length_2a(kv)) then + local i = 0 + for _, _22_0 in ipairs(kv) do + local _23_ = _22_0 + local k = _23_[1] + if (gap < (k - i)) then + gap = (k - i) + end + i = k + end + end + return gap + end + local function fill_gaps(kv) + local missing_indexes = {} + local i = 0 + for _, _26_0 in ipairs(kv) do + local _27_ = _26_0 + local j = _27_[1] + i = (i + 1) + while (i < j) do + table.insert(missing_indexes, i) + i = (i + 1) + end + end + for _, k in ipairs(missing_indexes) do + table.insert(kv, k, {k}) + end + return nil + end + local function table_kv_pairs(t, options) + if (("number" ~= type(options["max-sparse-gap"])) or (options["max-sparse-gap"] ~= math.floor(options["max-sparse-gap"]))) then + error(("max-sparse-gap must be an integer: got '%s'"):format(tostring(options["max-sparse-gap"]))) + end + local assoc_3f = false + local kv = {} + local insert = table.insert + for k, v in pairs(t) do + if (("number" ~= type(k)) or (k < 1) or (k ~= math.floor(k))) then + assoc_3f = true + end + insert(kv, {k, v}) + end + table.sort(kv, sort_keys) + if not assoc_3f then + if (options["max-sparse-gap"] < max_index_gap(kv)) then + assoc_3f = true + else + fill_gaps(kv) + end + end + if (length_2a(kv) == 0) then + return kv, "empty" + else + local function _32_() + if assoc_3f then + return "table" + else + return "seq" + end + end + return kv, _32_() + end + end + local function count_table_appearances(t, appearances) + if (type(t) == "table") then + if not appearances[t] then + appearances[t] = 1 + for k, v in pairs(t) do + count_table_appearances(k, appearances) + count_table_appearances(v, appearances) + end + else + appearances[t] = ((appearances[t] or 0) + 1) + end + end + return appearances + end + local function save_table(t, seen) + local seen0 = (seen or {len = 0}) + local id = (seen0.len + 1) + if not seen0[t] then + seen0[t] = id + seen0.len = id + end + return seen0 + end + local function detect_cycle(t, seen) + if ("table" == type(t)) then + seen[t] = true + local res = nil + for k, v in pairs(t) do + if res then break end + res = (seen[k] or detect_cycle(k, seen) or seen[v] or detect_cycle(v, seen)) + end + return res + end + end + local function visible_cycle_3f(t, options) + return (getopt(options, "detect-cycles?") and detect_cycle(t, {}) and save_table(t, options.seen) and (1 < (options.appearances[t] or 0))) + end + local function table_indent(indent, id) + local opener_length = nil + if id then + opener_length = (length_2a(tostring(id)) + 2) + else + opener_length = 1 + end + return (indent + opener_length) + end + local pp = nil + local function concat_table_lines(elements, options, multiline_3f, indent, table_type, prefix, last_comment_3f) + local indent_str = ("\n" .. string.rep(" ", indent)) + local open = nil + local function _39_() + if ("seq" == table_type) then + return "[" + else + return "{" + end + end + open = ((prefix or "") .. _39_()) + local close = nil + if ("seq" == table_type) then + close = "]" + else + close = "}" + end + local oneline = (open .. table.concat(elements, " ") .. close) + if (not getopt(options, "one-line?") and (multiline_3f or (options["line-length"] < (indent + length_2a(oneline))) or last_comment_3f)) then + local function _41_() + if last_comment_3f then + return indent_str + else + return "" + end + end + return (open .. table.concat(elements, indent_str) .. _41_() .. close) + else + return oneline + end + end + local function utf8_len(x) + local n = 0 + for _ in string.gmatch(x, "[%z\1-\127\192-\247]") do + n = (n + 1) + end + return n + end + local function comment_3f(x) + if ("table" == type(x)) then + local fst = x[1] + return (("string" == type(fst)) and (nil ~= fst:find("^;"))) + else + return false + end + end + local function pp_associative(t, kv, options, indent) + local multiline_3f = false + local id = options.seen[t] + if (options.depth <= options.level) then + return "{...}" + elseif (id and getopt(options, "detect-cycles?")) then + return ("@" .. id .. "{...}") + else + local visible_cycle_3f0 = visible_cycle_3f(t, options) + local id0 = (visible_cycle_3f0 and options.seen[t]) + local indent0 = table_indent(indent, id0) + local slength = nil + if getopt(options, "utf8?") then + slength = utf8_len + else + local function _44_(_241) + return #_241 + end + slength = _44_ + end + local prefix = nil + if visible_cycle_3f0 then + prefix = ("@" .. id0) + else + prefix = "" + end + local items = nil + do + local options0 = normalize_opts(options) + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for _, _47_0 in ipairs(kv) do + local _48_ = _47_0 + local k = _48_[1] + local v = _48_[2] + local val_19_ = nil + do + local k0 = pp(k, options0, (indent0 + 1), true) + local v0 = pp(v, options0, (indent0 + slength(k0) + 1)) + multiline_3f = (multiline_3f or k0:find("\n") or v0:find("\n")) + val_19_ = (k0 .. " " .. v0) + end + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + items = tbl_17_ + end + return concat_table_lines(items, options, multiline_3f, indent0, "table", prefix, false) + end + end + local function pp_sequence(t, kv, options, indent) + local multiline_3f = false + local id = options.seen[t] + if (options.depth <= options.level) then + return "[...]" + elseif (id and getopt(options, "detect-cycles?")) then + return ("@" .. id .. "[...]") + else + local visible_cycle_3f0 = visible_cycle_3f(t, options) + local id0 = (visible_cycle_3f0 and options.seen[t]) + local indent0 = table_indent(indent, id0) + local prefix = nil + if visible_cycle_3f0 then + prefix = ("@" .. id0) + else + prefix = "" + end + local last_comment_3f = comment_3f(t[#t]) + local items = nil + do + local options0 = normalize_opts(options) + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for _, _52_0 in ipairs(kv) do + local _53_ = _52_0 + local _0 = _53_[1] + local v = _53_[2] + local val_19_ = nil + do + local v0 = pp(v, options0, indent0) + multiline_3f = (multiline_3f or v0:find("\n") or v0:find("^;")) + val_19_ = v0 + end + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + items = tbl_17_ + end + return concat_table_lines(items, options, multiline_3f, indent0, "seq", prefix, last_comment_3f) + end + end + local function concat_lines(lines, options, indent, force_multi_line_3f) + if (length_2a(lines) == 0) then + if getopt(options, "empty-as-sequence?") then + return "[]" + else + return "{}" + end + else + local oneline = nil + local _57_ + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for _, line in ipairs(lines) do + local val_19_ = line:gsub("^%s+", "") + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + _57_ = tbl_17_ + end + oneline = table.concat(_57_, " ") + if (not getopt(options, "one-line?") and (force_multi_line_3f or oneline:find("\n") or (options["line-length"] < (indent + length_2a(oneline))))) then + return table.concat(lines, ("\n" .. string.rep(" ", indent))) + else + return oneline + end + end + end + local function pp_metamethod(t, metamethod, options, indent) + if (options.depth <= options.level) then + if getopt(options, "empty-as-sequence?") then + return "[...]" + else + return "{...}" + end + else + local _ = nil + local function _62_(_241) + return visible_cycle_3f(_241, options) + end + options["visible-cycle?"] = _62_ + _ = nil + local lines, force_multi_line_3f = nil, nil + do + local options0 = normalize_opts(options) + lines, force_multi_line_3f = metamethod(t, pp, options0, indent) + end + options["visible-cycle?"] = nil + local _63_0 = type(lines) + if (_63_0 == "string") then + return lines + elseif (_63_0 == "table") then + return concat_lines(lines, options, indent, force_multi_line_3f) + else + local _0 = _63_0 + return error("__fennelview metamethod must return a table of lines") + end + end + end + local function pp_table(x, options, indent) + options.level = (options.level + 1) + local x0 = nil + do + local _66_0 = nil + if getopt(options, "metamethod?") then + local _67_0 = x + if (nil ~= _67_0) then + local _68_0 = getmetatable(_67_0) + if (nil ~= _68_0) then + _66_0 = _68_0.__fennelview + else + _66_0 = _68_0 + end + else + _66_0 = _67_0 + end + else + _66_0 = nil + end + if (nil ~= _66_0) then + local metamethod = _66_0 + x0 = pp_metamethod(x, metamethod, options, indent) + else + local _ = _66_0 + local _72_0, _73_0 = table_kv_pairs(x, options) + if (true and (_73_0 == "empty")) then + local _0 = _72_0 + if getopt(options, "empty-as-sequence?") then + x0 = "[]" + else + x0 = "{}" + end + elseif ((nil ~= _72_0) and (_73_0 == "table")) then + local kv = _72_0 + x0 = pp_associative(x, kv, options, indent) + elseif ((nil ~= _72_0) and (_73_0 == "seq")) then + local kv = _72_0 + x0 = pp_sequence(x, kv, options, indent) + else + x0 = nil + end + end + end + options.level = (options.level - 1) + return x0 + end + local function exponential_notation(n, fallback) + local s = nil + for i = 0, 99 do + if s then break end + local s0 = string.format(("%." .. i .. "e"), n) + if (n == tonumber(s0)) then + local exp = s0:match("e%+?(%d+)$") + if (exp and (14 < tonumber(exp))) then + s = s0 + else + s = fallback + end + else + s = nil + end + end + return s + end + local inf_str = tostring((1 / 0)) + local neg_inf_str = tostring((-1 / 0)) + local function number__3estring(n, options) + local val = nil + if (n ~= n) then + if (45 == string.byte(tostring(n))) then + val = (options["negative-nan"] or "-.nan") + else + val = (options.nan or ".nan") + end + elseif (math.floor(n) == n) then + local s1 = string.format("%.0f", n) + if (s1 == inf_str) then + val = (options.infinity or ".inf") + elseif (s1 == neg_inf_str) then + val = (options["negative-infinity"] or "-.inf") + elseif (s1 == tostring(n)) then + val = s1 + else + val = (exponential_notation(n, s1) or s1) + end + else + val = tostring(n) + end + local _82_0 = string.gsub(val, ",", ".") + return _82_0 + end + local function colon_string_3f(s) + return s:find("^[-%w?^_!$%&*+./|<=>]+$") + end + local utf8_inits = {{["max-byte"] = 127, ["max-code"] = 127, ["min-byte"] = 0, ["min-code"] = 0, len = 1}, {["max-byte"] = 223, ["max-code"] = 2047, ["min-byte"] = 192, ["min-code"] = 128, len = 2}, {["max-byte"] = 239, ["max-code"] = 65535, ["min-byte"] = 224, ["min-code"] = 2048, len = 3}, {["max-byte"] = 247, ["max-code"] = 1114111, ["min-byte"] = 240, ["min-code"] = 65536, len = 4}} + local function default_byte_escape(byte, _options) + return ("\\%03d"):format(byte) + end + local function utf8_escape(str, options) + local function validate_utf8(str0, index) + local inits = utf8_inits + local byte = string.byte(str0, index) + local init = nil + do + local ret = nil + for _, init0 in ipairs(inits) do + if ret then break end + ret = (byte and (function(_83_,_84_,_85_) return (_83_ <= _84_) and (_84_ <= _85_) end)(init0["min-byte"],byte,init0["max-byte"]) and init0) + end + init = ret + end + local code = nil + local function _86_() + local code0 = nil + if init then + code0 = (byte - init["min-byte"]) + else + code0 = nil + end + for i = (index + 1), (index + init.len + -1) do + local byte0 = string.byte(str0, i) + code0 = (byte0 and code0 and ((128 <= byte0) and (byte0 <= 191)) and ((code0 * 64) + (byte0 - 128))) + end + return code0 + end + code = (init and _86_()) + if (code and (function(_88_,_89_,_90_) return (_88_ <= _89_) and (_89_ <= _90_) end)(init["min-code"],code,init["max-code"]) and not ((55296 <= code) and (code <= 57343))) then + return init.len + end + end + local index = 1 + local output = {} + local byte_escape = (getopt(options, "byte-escape") or default_byte_escape) + while (index <= #str) do + local nexti = (string.find(str, "[\128-\255]", index) or (#str + 1)) + local len = validate_utf8(str, nexti) + table.insert(output, string.sub(str, index, (nexti + (len or 0) + -1))) + if (not len and (nexti <= #str)) then + table.insert(output, byte_escape(str:byte(nexti), options)) + end + if len then + index = (nexti + len) + else + index = (nexti + 1) + end + end + return table.concat(output) + end + local function pp_string(str, options, indent) + local len = length_2a(str) + local esc_newline_3f = ((len < 2) or (getopt(options, "escape-newlines?") and (len < (options["line-length"] - indent)))) + local byte_escape = (getopt(options, "byte-escape") or default_byte_escape) + local escs = nil + local _94_ + if esc_newline_3f then + _94_ = "\\n" + else + _94_ = "\n" + end + local function _96_(_241, _242) + return byte_escape(_242:byte(), options) + end + escs = setmetatable({["\""] = "\\\"", ["\11"] = "\\v", ["\12"] = "\\f", ["\13"] = "\\r", ["\7"] = "\\a", ["\8"] = "\\b", ["\9"] = "\\t", ["\\"] = "\\\\", ["\n"] = _94_}, {__index = _96_}) + local str0 = ("\"" .. str:gsub("[%c\\\"]", escs) .. "\"") + if getopt(options, "utf8?") then + return utf8_escape(str0, options) + else + return str0 + end + end + local function make_options(t, options) + local defaults = nil + do + local tbl_14_ = {} + for k, v in pairs(default_opts) do + local k_15_, v_16_ = k, v + if ((k_15_ ~= nil) and (v_16_ ~= nil)) then + tbl_14_[k_15_] = v_16_ + end + end + defaults = tbl_14_ + end + local overrides = {appearances = count_table_appearances(t, {}), level = 0, seen = {len = 0}} + for k, v in pairs((options or {})) do + defaults[k] = v + end + for k, v in pairs(overrides) do + defaults[k] = v + end + return defaults + end + local function _99_(x, options, indent, colon_3f) + local indent0 = (indent or 0) + local options0 = (options or make_options(x)) + local x0 = nil + if options0.preprocess then + x0 = options0.preprocess(x, options0) + else + x0 = x + end + local tv = type(x0) + local function _102_() + local _101_0 = getmetatable(x0) + if ((_G.type(_101_0) == "table") and true) then + local __fennelview = _101_0.__fennelview + return __fennelview + end + end + if ((tv == "table") or ((tv == "userdata") and _102_())) then + return pp_table(x0, options0, indent0) + elseif (tv == "number") then + return number__3estring(x0, options0) + else + local function _104_() + if (colon_3f ~= nil) then + return colon_3f + elseif ("function" == type(options0["prefer-colon?"])) then + return options0["prefer-colon?"](x0) + else + return getopt(options0, "prefer-colon?") + end + end + if ((tv == "string") and colon_string_3f(x0) and _104_()) then + return (":" .. x0) + elseif (tv == "string") then + return pp_string(x0, options0, indent0) + elseif ((tv == "boolean") or (tv == "nil")) then + return tostring(x0) + else + return ("#<" .. tostring(x0) .. ">") + end + end + end + pp = _99_ + local function _view(x, _3foptions) + return pp(x, make_options(x, _3foptions), 0) + end + return _view +end +package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(...) + local view = require("fennel.view") + local version = "1.5.3" + local unpack = (table.unpack or _G.unpack) + local pack = nil + local function _106_(...) + local _107_0 = {...} + _107_0["n"] = select("#", ...) + return _107_0 + end + pack = (table.pack or _106_) + local maxn = nil + local function _108_(_241) + local max = 0 + for k in pairs(_241) do + if (("number" == type(k)) and (max < k)) then + max = k + else + max = max + end + end + return max + end + maxn = (table.maxn or _108_) + local function luajit_vm_3f() + return ((nil ~= _G.jit) and (type(_G.jit) == "table") and (nil ~= _G.jit.on) and (nil ~= _G.jit.off) and (type(_G.jit.version_num) == "number")) + end + local function luajit_vm_version() + local jit_os = nil + if (_G.jit.os == "OSX") then + jit_os = "macOS" + else + jit_os = _G.jit.os + end + return (_G.jit.version .. " " .. jit_os .. "/" .. _G.jit.arch) + end + local function fengari_vm_3f() + return ((nil ~= _G.fengari) and (type(_G.fengari) == "table") and (nil ~= _G.fengari.VERSION) and (type(_G.fengari.VERSION_NUM) == "number")) + end + local function fengari_vm_version() + return (_G.fengari.RELEASE .. " (" .. _VERSION .. ")") + end + local function lua_vm_version() + if luajit_vm_3f() then + return luajit_vm_version() + elseif fengari_vm_3f() then + return fengari_vm_version() + else + return ("PUC " .. _VERSION) + end + end + local function runtime_version(_3fas_table) + if _3fas_table then + return {fennel = version, lua = lua_vm_version()} + else + return ("Fennel " .. version .. " on " .. lua_vm_version()) + end + end + local len = nil + do + local _113_0, _114_0 = pcall(require, "utf8") + if ((_113_0 == true) and (nil ~= _114_0)) then + local utf8 = _114_0 + len = utf8.len + else + local _ = _113_0 + len = string.len + end + end + local kv_order = {boolean = 2, number = 1, string = 3, table = 4} + local function kv_compare(a, b) + local _116_0, _117_0 = type(a), type(b) + if (((_116_0 == "number") and (_117_0 == "number")) or ((_116_0 == "string") and (_117_0 == "string"))) then + return (a < b) + else + local function _118_() + local a_t = _116_0 + local b_t = _117_0 + return (a_t ~= b_t) + end + if (((nil ~= _116_0) and (nil ~= _117_0)) and _118_()) then + local a_t = _116_0 + local b_t = _117_0 + return ((kv_order[a_t] or 5) < (kv_order[b_t] or 5)) + else + local _ = _116_0 + return (tostring(a) < tostring(b)) + end + end + end + local function add_stable_keys(succ, prev_key, src, _3fpred) + local first = prev_key + local last = nil + do + local prev = prev_key + for _, k in ipairs(src) do + if ((prev == k) or (succ[k] ~= nil) or (_3fpred and not _3fpred(k))) then + prev = prev + else + if (first == nil) then + first = k + prev = k + elseif (prev ~= nil) then + succ[prev] = k + prev = k + else + prev = k + end + end + end + last = prev + end + return succ, last, first + end + local function stablepairs(t) + local mt_keys = nil + do + local _122_0 = getmetatable(t) + if (nil ~= _122_0) then + _122_0 = _122_0.keys + end + mt_keys = _122_0 + end + local succ, prev, first_mt = nil, nil, nil + local function _124_(_241) + return t[_241] + end + succ, prev, first_mt = add_stable_keys({}, nil, (mt_keys or {}), _124_) + local pairs_keys = nil + do + local _125_0 = nil + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for k in pairs(t) do + local val_19_ = k + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + _125_0 = tbl_17_ + end + table.sort(_125_0, kv_compare) + pairs_keys = _125_0 + end + local succ0, _, first_after_mt = add_stable_keys(succ, prev, pairs_keys) + local first = nil + if (first_mt == nil) then + first = first_after_mt + else + first = first_mt + end + local function stablenext(tbl, key) + local _128_0 = nil + if (key == nil) then + _128_0 = first + else + _128_0 = succ0[key] + end + if (nil ~= _128_0) then + local next_key = _128_0 + local _130_0 = tbl[next_key] + if (_130_0 ~= nil) then + return next_key, _130_0 + else + return _130_0 + end + end + end + return stablenext, t, nil + end + local function get_in(tbl, path) + if (nil ~= path[1]) then + local t = tbl + for _, k in ipairs(path) do + if (nil == t) then break end + if (type(t) == "table") then + t = t[k] + else + t = nil + end + end + return t + end + end + local function copy(_3ffrom, _3fto) + local tbl_14_ = (_3fto or {}) + for k, v in pairs((_3ffrom or {})) do + local k_15_, v_16_ = k, v + if ((k_15_ ~= nil) and (v_16_ ~= nil)) then + tbl_14_[k_15_] = v_16_ + end + end + return tbl_14_ + end + local function member_3f(x, tbl, _3fn) + local _136_0 = tbl[(_3fn or 1)] + if (_136_0 == x) then + return true + elseif (_136_0 == nil) then + return nil + else + local _ = _136_0 + return member_3f(x, tbl, ((_3fn or 1) + 1)) + end + end + local function every_3f(t, predicate) + local result = true + for _, item in ipairs(t) do + if not result then break end + result = predicate(item) + end + return result + end + local function allpairs(tbl) + assert((type(tbl) == "table"), "allpairs expects a table") + local t = tbl + local seen = {} + local function allpairs_next(_, state) + local next_state, value = next(t, state) + if seen[next_state] then + return allpairs_next(nil, next_state) + elseif next_state then + seen[next_state] = true + return next_state, value + else + local _138_0 = getmetatable(t) + if ((_G.type(_138_0) == "table") and true) then + local __index = _138_0.__index + if ("table" == type(__index)) then + t = __index + return allpairs_next(t) + end + end + end + end + return allpairs_next + end + local function deref(self) + return self[1] + end + local function list__3estring(self, _3fview, _3foptions, _3findent) + local viewed = nil + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for i = 1, maxn(self) do + local val_19_ = nil + if _3fview then + val_19_ = _3fview(self[i], _3foptions, _3findent) + else + val_19_ = view(self[i]) + end + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + viewed = tbl_17_ + end + return ("(" .. table.concat(viewed, " ") .. ")") + end + local function sym_3d(a, b) + return ((deref(a) == deref(b)) and (getmetatable(a) == getmetatable(b))) + end + local function sym_3c(a, b) + return (a[1] < tostring(b)) + end + local symbol_mt = {"SYMBOL", __eq = sym_3d, __fennelview = deref, __lt = sym_3c, __tostring = deref} + local expr_mt = nil + local function _144_(x) + return tostring(deref(x)) + end + expr_mt = {"EXPR", __tostring = _144_} + local list_mt = {"LIST", __fennelview = list__3estring, __tostring = list__3estring} + local comment_mt = nil + local function _145_(_241) + return _241 + end + comment_mt = {"COMMENT", __eq = sym_3d, __fennelview = _145_, __lt = sym_3c, __tostring = deref} + local sequence_marker = {"SEQUENCE"} + local varg_mt = {"VARARG", __fennelview = deref, __tostring = deref} + local getenv = nil + local function _146_() + return nil + end + getenv = ((os and os.getenv) or _146_) + local function debug_on_3f(flag) + local level = (getenv("FENNEL_DEBUG") or "") + return ((level == "all") or level:find(flag)) + end + local function list(...) + return setmetatable({...}, list_mt) + end + local function sym(str, _3fsource) + local _147_ + do + local tbl_14_ = {str} + for k, v in pairs((_3fsource or {})) do + local k_15_, v_16_ = nil, nil + if (type(k) == "string") then + k_15_, v_16_ = k, v + else + k_15_, v_16_ = nil + end + if ((k_15_ ~= nil) and (v_16_ ~= nil)) then + tbl_14_[k_15_] = v_16_ + end + end + _147_ = tbl_14_ + end + return setmetatable(_147_, symbol_mt) + end + local function sequence(...) + local function _150_(seq, view0, inspector, indent) + local opts = nil + do + inspector["empty-as-sequence?"] = {after = inspector["empty-as-sequence?"], once = true} + inspector["metamethod?"] = {after = inspector["metamethod?"], once = false} + opts = inspector + end + return view0(seq, opts, indent) + end + return setmetatable({...}, {__fennelview = _150_, sequence = sequence_marker}) + end + local function expr(strcode, etype) + return setmetatable({strcode, type = etype}, expr_mt) + end + local function comment_2a(contents, _3fsource) + local _151_ = (_3fsource or {}) + local filename = _151_["filename"] + local line = _151_["line"] + return setmetatable({contents, filename = filename, line = line}, comment_mt) + end + local function varg(_3fsource) + local _152_ + do + local tbl_14_ = {"..."} + for k, v in pairs((_3fsource or {})) do + local k_15_, v_16_ = nil, nil + if (type(k) == "string") then + k_15_, v_16_ = k, v + else + k_15_, v_16_ = nil + end + if ((k_15_ ~= nil) and (v_16_ ~= nil)) then + tbl_14_[k_15_] = v_16_ + end + end + _152_ = tbl_14_ + end + return setmetatable(_152_, varg_mt) + end + local function expr_3f(x) + return ((type(x) == "table") and (getmetatable(x) == expr_mt) and x) + end + local function varg_3f(x) + return ((type(x) == "table") and (getmetatable(x) == varg_mt) and x) + end + local function list_3f(x) + return ((type(x) == "table") and (getmetatable(x) == list_mt) and x) + end + local function sym_3f(x, _3fname) + return ((type(x) == "table") and (getmetatable(x) == symbol_mt) and ((nil == _3fname) or (x[1] == _3fname)) and x) + end + local function sequence_3f(x) + local mt = ((type(x) == "table") and getmetatable(x)) + return (mt and (mt.sequence == sequence_marker) and x) + end + local function comment_3f(x) + return ((type(x) == "table") and (getmetatable(x) == comment_mt) and x) + end + local function table_3f(x) + return ((type(x) == "table") and not varg_3f(x) and (getmetatable(x) ~= list_mt) and (getmetatable(x) ~= symbol_mt) and not comment_3f(x) and x) + end + local function kv_table_3f(t) + if table_3f(t) then + local nxt, t0, k = pairs(t) + local len0 = #t0 + local next_state = nil + if (0 == len0) then + next_state = k + else + next_state = len0 + end + return ((nil ~= nxt(t0, next_state)) and t0) + end + end + local function string_3f(x) + if (type(x) == "string") then + return x + else + return false + end + end + local function multi_sym_3f(str) + if sym_3f(str) then + return multi_sym_3f(tostring(str)) + elseif (type(str) ~= "string") then + return false + else + local function _158_() + local parts = {} + for part in str:gmatch("[^%.%:]+[%.%:]?") do + local last_char = part:sub(-1) + if (last_char == ":") then + parts["multi-sym-method-call"] = true + end + if ((last_char == ":") or (last_char == ".")) then + parts[(#parts + 1)] = part:sub(1, -2) + else + parts[(#parts + 1)] = part + end + end + return (next(parts) and parts) + end + return ((str:match("%.") or str:match(":")) and not str:match("%.%.") and (str:byte() ~= string.byte(".")) and (str:byte() ~= string.byte(":")) and (str:byte(-1) ~= string.byte(".")) and (str:byte(-1) ~= string.byte(":")) and _158_()) + end + end + local function call_of_3f(ast, callee) + return (list_3f(ast) and sym_3f(ast[1], callee)) + end + local function quoted_3f(symbol) + return symbol.quoted + end + local function idempotent_expr_3f(x) + local t = type(x) + return ((t == "string") or (t == "number") or (t == "boolean") or (sym_3f(x) and not multi_sym_3f(x))) + end + local function walk_tree(root, f, _3fcustom_iterator) + local function walk(iterfn, parent, idx, node) + if (f(idx, node, parent) and not sym_3f(node)) then + for k, v in iterfn(node) do + walk(iterfn, node, k, v) + end + return nil + end + end + walk((_3fcustom_iterator or pairs), nil, nil, root) + return root + end + local root = nil + local function _163_() + end + root = {chunk = nil, options = nil, reset = _163_, scope = nil} + root["set-reset"] = function(_164_0) + local _165_ = _164_0 + local chunk = _165_["chunk"] + local options = _165_["options"] + local reset = _165_["reset"] + local scope = _165_["scope"] + root.reset = function() + root.chunk, root.scope, root.options, root.reset = chunk, scope, options, reset + return nil + end + return root.reset + end + local lua_keywords = {["and"] = true, ["break"] = true, ["do"] = true, ["else"] = true, ["elseif"] = true, ["end"] = true, ["false"] = true, ["for"] = true, ["function"] = true, ["goto"] = true, ["if"] = true, ["in"] = true, ["local"] = true, ["nil"] = true, ["not"] = true, ["or"] = true, ["repeat"] = true, ["return"] = true, ["then"] = true, ["true"] = true, ["until"] = true, ["while"] = true} + local function lua_keyword_3f(str) + local function _167_() + local _166_0 = root.options + if (nil ~= _166_0) then + _166_0 = _166_0.keywords + end + if (nil ~= _166_0) then + _166_0 = _166_0[str] + end + return _166_0 + end + return (lua_keywords[str] or _167_()) + end + local function valid_lua_identifier_3f(str) + return (str:match("^[%a_][%w_]*$") and not lua_keyword_3f(str)) + end + local propagated_options = {"allowedGlobals", "indent", "correlate", "useMetadata", "env", "compiler-env", "compilerEnv"} + local function propagate_options(options, subopts) + local tbl_14_ = subopts + for _, name in ipairs(propagated_options) do + local k_15_, v_16_ = name, options[name] + if ((k_15_ ~= nil) and (v_16_ ~= nil)) then + tbl_14_[k_15_] = v_16_ + end + end + return tbl_14_ + end + local function ast_source(ast) + if (table_3f(ast) or sequence_3f(ast)) then + return (getmetatable(ast) or {}) + elseif ("table" == type(ast)) then + return ast + else + return {} + end + end + local function warn(msg, _3fast, _3ffilename, _3fline) + local _172_0 = nil + do + local _173_0 = root.options + if (nil ~= _173_0) then + _173_0 = _173_0.warn + end + _172_0 = _173_0 + end + if (nil ~= _172_0) then + local opt_warn = _172_0 + return opt_warn(msg, _3fast, _3ffilename, _3fline) + else + local _ = _172_0 + if (_G.io and _G.io.stderr) then + local loc = nil + do + local _175_0 = ast_source(_3fast) + if ((_G.type(_175_0) == "table") and (nil ~= _175_0.filename) and (nil ~= _175_0.line)) then + local filename = _175_0.filename + local line = _175_0.line + loc = (filename .. ":" .. line .. ": ") + else + local _0 = _175_0 + if (_3ffilename and _3fline) then + loc = (_3ffilename .. ":" .. _3fline .. ": ") + else + loc = "" + end + end + end + return (_G.io.stderr):write(("--WARNING: %s%s\n"):format(loc, msg)) + end + end + end + local warned = {} + local function check_plugin_version(_180_0) + local _181_ = _180_0 + local plugin = _181_ + local name = _181_["name"] + local versions = _181_["versions"] + if (not member_3f(version:gsub("-dev", ""), (versions or {})) and not (string_3f(versions) and version:find(versions)) and not warned[plugin]) then + warned[plugin] = true + return warn(string.format("plugin %s does not support Fennel version %s", (name or "unknown"), version)) + end + end + local function hook_opts(event, _3foptions, ...) + local plugins = nil + local function _184_(...) + local _183_0 = _3foptions + if (nil ~= _183_0) then + _183_0 = _183_0.plugins + end + return _183_0 + end + local function _187_(...) + local _186_0 = root.options + if (nil ~= _186_0) then + _186_0 = _186_0.plugins + end + return _186_0 + end + plugins = (_184_(...) or _187_(...)) + if plugins then + local result = nil + for _, plugin in ipairs(plugins) do + if (nil ~= result) then break end + check_plugin_version(plugin) + local _189_0 = plugin[event] + if (nil ~= _189_0) then + local f = _189_0 + result = f(...) + else + result = nil + end + end + return result + end + end + local function hook(event, ...) + return hook_opts(event, root.options, ...) + end + return {["ast-source"] = ast_source, ["call-of?"] = call_of_3f, ["comment?"] = comment_3f, ["debug-on?"] = debug_on_3f, ["every?"] = every_3f, ["expr?"] = expr_3f, ["fennel-module"] = nil, ["get-in"] = get_in, ["hook-opts"] = hook_opts, ["idempotent-expr?"] = idempotent_expr_3f, ["kv-table?"] = kv_table_3f, ["list?"] = list_3f, ["lua-keyword?"] = lua_keyword_3f, ["macro-path"] = table.concat({"./?.fnl", "./?/init-macros.fnl", "./?/init.fnl", getenv("FENNEL_MACRO_PATH")}, ";"), ["member?"] = member_3f, ["multi-sym?"] = multi_sym_3f, ["propagate-options"] = propagate_options, ["quoted?"] = quoted_3f, ["runtime-version"] = runtime_version, ["sequence?"] = sequence_3f, ["string?"] = string_3f, ["sym?"] = sym_3f, ["table?"] = table_3f, ["valid-lua-identifier?"] = valid_lua_identifier_3f, ["varg?"] = varg_3f, ["walk-tree"] = walk_tree, allpairs = allpairs, comment = comment_2a, copy = copy, expr = expr, hook = hook, len = len, list = list, maxn = maxn, pack = pack, path = table.concat({"./?.fnl", "./?/init.fnl", getenv("FENNEL_PATH")}, ";"), root = root, sequence = sequence, stablepairs = stablepairs, sym = sym, unpack = unpack, varg = varg, version = version, warn = warn} +end +utils = require("fennel.utils") +local parser = require("fennel.parser") +local compiler = require("fennel.compiler") +local specials = require("fennel.specials") +local repl = require("fennel.repl") +local view = require("fennel.view") +local function eval_env(env, opts) + if (env == "_COMPILER") then + local env0 = specials["make-compiler-env"](nil, compiler.scopes.compiler, {}, opts) + if (opts.allowedGlobals == nil) then + opts.allowedGlobals = specials["current-global-names"](env0) + end + return specials["wrap-env"](env0) + else + return (env and specials["wrap-env"](env)) + end +end +local function eval_opts(options, str) + local opts = utils.copy(options) + if (opts.allowedGlobals == nil) then + opts.allowedGlobals = specials["current-global-names"](opts.env) + end + if (not opts.filename and not opts.source) then + opts.source = str + end + if (opts.env == "_COMPILER") then + opts.scope = compiler["make-scope"](compiler.scopes.compiler) + end + return opts +end +local function eval(str, _3foptions, ...) + local opts = eval_opts(_3foptions, str) + local env = eval_env(opts.env, opts) + local lua_source = compiler["compile-string"](str, opts) + local loader = nil + local function _858_(...) + if opts.filename then + return ("@" .. opts.filename) + else + return str + end + end + loader = specials["load-code"](lua_source, env, _858_(...)) + opts.filename = nil + return loader(...) +end +local function dofile_2a(filename, _3foptions, ...) + local opts = utils.copy(_3foptions) + local f = assert(io.open(filename, "rb")) + local source = assert(f:read("*all"), ("Could not read " .. filename)) + f:close() + opts.filename = filename + return eval(source, opts, ...) +end +local function syntax() + local body_3f = {"when", "with-open", "collect", "icollect", "fcollect", "lambda", "\206\187", "macro", "match", "match-try", "case", "case-try", "accumulate", "faccumulate", "doto"} + local binding_3f = {"collect", "icollect", "fcollect", "each", "for", "let", "with-open", "accumulate", "faccumulate"} + local define_3f = {"fn", "lambda", "\206\187", "var", "local", "macro", "macros", "global"} + local deprecated = {"~=", "#", "global", "require-macros", "pick-args"} + local out = {} + for k, v in pairs(compiler.scopes.global.specials) do + local metadata = (compiler.metadata[v] or {}) + out[k] = {["binding-form?"] = utils["member?"](k, binding_3f), ["body-form?"] = metadata["fnl/body-form?"], ["define?"] = utils["member?"](k, define_3f), ["deprecated?"] = utils["member?"](k, deprecated), ["special?"] = true} + end + for k in pairs(compiler.scopes.global.macros) do + out[k] = {["binding-form?"] = utils["member?"](k, binding_3f), ["body-form?"] = utils["member?"](k, body_3f), ["define?"] = utils["member?"](k, define_3f), ["macro?"] = true} + end + for k, v in pairs(_G) do + local _859_0 = type(v) + if (_859_0 == "function") then + out[k] = {["function?"] = true, ["global?"] = true} + elseif (_859_0 == "table") then + if not k:find("^_") then + for k2, v2 in pairs(v) do + if ("function" == type(v2)) then + out[(k .. "." .. k2)] = {["function?"] = true, ["global?"] = true} + end + end + out[k] = {["global?"] = true} + end + end + end + return out +end +local mod = {["ast-source"] = utils["ast-source"], ["comment?"] = utils["comment?"], ["compile-stream"] = compiler["compile-stream"], ["compile-string"] = compiler["compile-string"], ["list?"] = utils["list?"], ["load-code"] = specials["load-code"], ["macro-loaded"] = specials["macro-loaded"], ["macro-path"] = utils["macro-path"], ["macro-searchers"] = specials["macro-searchers"], ["make-searcher"] = specials["make-searcher"], ["multi-sym?"] = utils["multi-sym?"], ["runtime-version"] = utils["runtime-version"], ["search-module"] = specials["search-module"], ["sequence?"] = utils["sequence?"], ["string-stream"] = parser["string-stream"], ["sym-char?"] = parser["sym-char?"], ["sym?"] = utils["sym?"], ["table?"] = utils["table?"], ["varg?"] = utils["varg?"], comment = utils.comment, compile = compiler.compile, compile1 = compiler.compile1, compileStream = compiler["compile-stream"], compileString = compiler["compile-string"], doc = specials.doc, dofile = dofile_2a, eval = eval, gensym = compiler.gensym, getinfo = compiler.getinfo, granulate = parser.granulate, list = utils.list, loadCode = specials["load-code"], macroLoaded = specials["macro-loaded"], macroPath = utils["macro-path"], macroSearchers = specials["macro-searchers"], makeSearcher = specials["make-searcher"], make_searcher = specials["make-searcher"], mangle = compiler["global-mangling"], metadata = compiler.metadata, parser = parser.parser, path = utils.path, repl = repl, runtimeVersion = utils["runtime-version"], scope = compiler["make-scope"], searchModule = specials["search-module"], searcher = specials["make-searcher"](), sequence = utils.sequence, stringStream = parser["string-stream"], sym = utils.sym, syntax = syntax, traceback = compiler.traceback, unmangle = compiler["global-unmangling"], varg = utils.varg, version = utils.version, view = view} +mod.install = function(_3fopts) + table.insert((package.searchers or package.loaders), specials["make-searcher"](_3fopts)) + return mod +end +utils["fennel-module"] = mod +local function load_macros(src, env) + local chunk = assert(specials["load-code"](src, env, "src/fennel/macros.fnl")) + for k, v in pairs(chunk()) do + compiler.scopes.global.macros[k] = v + end + return nil +end +do + local env = specials["make-compiler-env"](nil, compiler.scopes.compiler, {}) + env.utils = utils + env["get-function-metadata"] = specials["get-function-metadata"] + load_macros([===[local function copy(t) + local out = {} + for _, v in ipairs(t) do + table.insert(out, v) + end + return setmetatable(out, getmetatable(t)) + end + utils['fennel-module'].metadata:setall(copy, "fnl/arglist", {"t"}) + local function __3e_2a(val, ...) + local x = val + for _, e in ipairs({...}) do + local elt = nil + if _G["list?"](e) then + elt = copy(e) + else + elt = list(e) + end + table.insert(elt, 2, x) + x = elt + end + return x + end + utils['fennel-module'].metadata:setall(__3e_2a, "fnl/arglist", {"val", "..."}, "fnl/docstring", "Thread-first macro.\nTake the first value and splice it into the second form as its first argument.\nThe value of the second form is spliced into the first arg of the third, etc.") + local function __3e_3e_2a(val, ...) + local x = val + for _, e in ipairs({...}) do + local elt = nil + if _G["list?"](e) then + elt = copy(e) + else + elt = list(e) + end + table.insert(elt, x) + x = elt + end + return x + end + utils['fennel-module'].metadata:setall(__3e_3e_2a, "fnl/arglist", {"val", "..."}, "fnl/docstring", "Thread-last macro.\nSame as ->, except splices the value into the last position of each form\nrather than the first.") + local function __3f_3e_2a(val, _3fe, ...) + if (nil == _3fe) then + return val + elseif not utils["idempotent-expr?"](val) then + return setmetatable({filename="src/fennel/macros.fnl", line=40, bytestart=1174, sym('let', nil, {quoted=true, filename="src/fennel/macros.fnl", line=40}), setmetatable({sym('tmp_3_', nil, {filename="src/fennel/macros.fnl", line=40}), val}, {filename="src/fennel/macros.fnl", line=40}), setmetatable({filename="src/fennel/macros.fnl", line=41, bytestart=1199, sym('-?>', nil, {quoted=true, filename="src/fennel/macros.fnl", line=41}), sym('tmp_3_', nil, {filename="src/fennel/macros.fnl", line=41}), _3fe, ...}, getmetatable(list()))}, getmetatable(list())) + else + local call = nil + if _G["list?"](_3fe) then + call = copy(_3fe) + else + call = list(_3fe) + end + table.insert(call, 2, val) + return setmetatable({filename="src/fennel/macros.fnl", line=44, bytestart=1317, sym('if', nil, {quoted=true, filename="src/fennel/macros.fnl", line=44}), setmetatable({filename="src/fennel/macros.fnl", line=44, bytestart=1321, sym('not=', nil, {quoted=true, filename="src/fennel/macros.fnl", line=44}), sym('nil', nil, {quoted=true, filename="src/fennel/macros.fnl", line=44}), val}, getmetatable(list())), __3f_3e_2a(call, ...)}, getmetatable(list())) + end + end + utils['fennel-module'].metadata:setall(__3f_3e_2a, "fnl/arglist", {"val", "?e", "..."}, "fnl/docstring", "Nil-safe thread-first macro.\nSame as -> except will short-circuit with nil when it encounters a nil value.") + local function __3f_3e_3e_2a(val, _3fe, ...) + if (nil == _3fe) then + return val + elseif not utils["idempotent-expr?"](val) then + return setmetatable({filename="src/fennel/macros.fnl", line=54, bytestart=1627, sym('let', nil, {quoted=true, filename="src/fennel/macros.fnl", line=54}), setmetatable({sym('tmp_6_', nil, {filename="src/fennel/macros.fnl", line=54}), val}, {filename="src/fennel/macros.fnl", line=54}), setmetatable({filename="src/fennel/macros.fnl", line=55, bytestart=1652, sym('-?>>', nil, {quoted=true, filename="src/fennel/macros.fnl", line=55}), sym('tmp_6_', nil, {filename="src/fennel/macros.fnl", line=55}), _3fe, ...}, getmetatable(list()))}, getmetatable(list())) + else + local call = nil + if _G["list?"](_3fe) then + call = copy(_3fe) + else + call = list(_3fe) + end + table.insert(call, val) + return setmetatable({filename="src/fennel/macros.fnl", line=58, bytestart=1769, sym('if', nil, {quoted=true, filename="src/fennel/macros.fnl", line=58}), setmetatable({filename="src/fennel/macros.fnl", line=58, bytestart=1773, sym('not=', nil, {quoted=true, filename="src/fennel/macros.fnl", line=58}), val, sym('nil', nil, {quoted=true, filename="src/fennel/macros.fnl", line=58})}, getmetatable(list())), __3f_3e_3e_2a(call, ...)}, getmetatable(list())) + end + end + utils['fennel-module'].metadata:setall(__3f_3e_3e_2a, "fnl/arglist", {"val", "?e", "..."}, "fnl/docstring", "Nil-safe thread-last macro.\nSame as ->> except will short-circuit with nil when it encounters a nil value.") + local function _3fdot(tbl, ...) + local head = gensym("t") + local lookups = setmetatable({filename="src/fennel/macros.fnl", line=66, bytestart=2024, sym('do', nil, {quoted=true, filename="src/fennel/macros.fnl", line=66}), setmetatable({filename="src/fennel/macros.fnl", line=67, bytestart=2047, sym('var', nil, {quoted=true, filename="src/fennel/macros.fnl", line=67}), head, tbl}, getmetatable(list())), head}, getmetatable(list())) + for i, k in ipairs({...}) do + table.insert(lookups, (i + 2), setmetatable({filename="src/fennel/macros.fnl", line=73, bytestart=2335, sym('if', nil, {quoted=true, filename="src/fennel/macros.fnl", line=73}), setmetatable({filename="src/fennel/macros.fnl", line=73, bytestart=2339, sym('not=', nil, {quoted=true, filename="src/fennel/macros.fnl", line=73}), sym('nil', nil, {quoted=true, filename="src/fennel/macros.fnl", line=73}), head}, getmetatable(list())), setmetatable({filename="src/fennel/macros.fnl", line=73, bytestart=2356, sym('set', nil, {quoted=true, filename="src/fennel/macros.fnl", line=73}), head, setmetatable({filename="src/fennel/macros.fnl", line=73, bytestart=2367, sym('.', nil, {quoted=true, filename="src/fennel/macros.fnl", line=73}), head, k}, getmetatable(list()))}, getmetatable(list()))}, getmetatable(list()))) + end + return lookups + end + utils['fennel-module'].metadata:setall(_3fdot, "fnl/arglist", {"tbl", "..."}, "fnl/docstring", "Nil-safe table look up.\nSame as . (dot), except will short-circuit with nil when it encounters\na nil value in any of subsequent keys.") + local function doto_2a(val, ...) + assert((val ~= nil), "missing subject") + if not utils["idempotent-expr?"](val) then + return setmetatable({filename="src/fennel/macros.fnl", line=80, bytestart=2585, sym('let', nil, {quoted=true, filename="src/fennel/macros.fnl", line=80}), setmetatable({sym('tmp_9_', nil, {filename="src/fennel/macros.fnl", line=80}), val}, {filename="src/fennel/macros.fnl", line=80}), setmetatable({filename="src/fennel/macros.fnl", line=81, bytestart=2609, sym('doto', nil, {quoted=true, filename="src/fennel/macros.fnl", line=81}), sym('tmp_9_', nil, {filename="src/fennel/macros.fnl", line=81}), ...}, getmetatable(list()))}, getmetatable(list())) + else + local form = setmetatable({filename="src/fennel/macros.fnl", line=82, bytestart=2643, sym('do', nil, {quoted=true, filename="src/fennel/macros.fnl", line=82})}, getmetatable(list())) + for _, elt in ipairs({...}) do + local elt0 = nil + if _G["list?"](elt) then + elt0 = copy(elt) + else + elt0 = list(elt) + end + table.insert(elt0, 2, val) + table.insert(form, elt0) + end + table.insert(form, val) + return form + end + end + utils['fennel-module'].metadata:setall(doto_2a, "fnl/arglist", {"val", "..."}, "fnl/docstring", "Evaluate val and splice it into the first argument of subsequent forms.") + local function when_2a(condition, body1, ...) + assert(body1, "expected body") + return setmetatable({filename="src/fennel/macros.fnl", line=93, bytestart=2992, sym('if', nil, {quoted=true, filename="src/fennel/macros.fnl", line=93}), condition, setmetatable({filename="src/fennel/macros.fnl", line=94, bytestart=3014, sym('do', nil, {quoted=true, filename="src/fennel/macros.fnl", line=94}), body1, ...}, getmetatable(list()))}, getmetatable(list())) + end + utils['fennel-module'].metadata:setall(when_2a, "fnl/arglist", {"condition", "body1", "..."}, "fnl/docstring", "Evaluate body for side-effects only when condition is truthy.") + local function with_open_2a(closable_bindings, ...) + local bodyfn = setmetatable({filename="src/fennel/macros.fnl", line=102, bytestart=3312, sym('fn', nil, {quoted=true, filename="src/fennel/macros.fnl", line=102}), setmetatable({}, {filename="src/fennel/macros.fnl", line=102}), ...}, getmetatable(list())) + local closer = setmetatable({filename="src/fennel/macros.fnl", line=104, bytestart=3359, sym('fn', nil, {quoted=true, filename="src/fennel/macros.fnl", line=104}), sym('close-handlers_12_', nil, {filename="src/fennel/macros.fnl", line=104}), setmetatable({sym('ok_13_', nil, {filename="src/fennel/macros.fnl", line=104}), _VARARG}, {filename="src/fennel/macros.fnl", line=104}), setmetatable({filename="src/fennel/macros.fnl", line=105, bytestart=3407, sym('if', nil, {quoted=true, filename="src/fennel/macros.fnl", line=105}), sym('ok_13_', nil, {filename="src/fennel/macros.fnl", line=105}), _VARARG, setmetatable({filename="src/fennel/macros.fnl", line=105, bytestart=3419, sym('error', nil, {quoted=true, filename="src/fennel/macros.fnl", line=105}), _VARARG, 0}, getmetatable(list()))}, getmetatable(list()))}, getmetatable(list())) + local traceback = setmetatable({filename="src/fennel/macros.fnl", line=106, bytestart=3454, sym('.', nil, {quoted=true, filename="src/fennel/macros.fnl", line=106}), setmetatable({filename="src/fennel/macros.fnl", line=106, bytestart=3457, sym('or', nil, {quoted=true, filename="src/fennel/macros.fnl", line=106}), setmetatable({filename="src/fennel/macros.fnl", line=106, bytestart=3461, sym('?.', nil, {quoted=true, filename="src/fennel/macros.fnl", line=106}), sym('_G', nil, {quoted=true, filename="src/fennel/macros.fnl", line=106}), "package", "loaded", _G["fennel-module-name"]()}, getmetatable(list())), sym('_G.debug', nil, {quoted=true, filename="src/fennel/macros.fnl", line=107}), setmetatable({["traceback"]=setmetatable({filename=nil, line=nil, bytestart=nil, sym('hashfn', nil, {quoted=true, filename=nil, line=nil}), ""}, getmetatable(list()))}, {filename="src/fennel/macros.fnl", line=107})}, getmetatable(list())), "traceback"}, getmetatable(list())) + for i = 1, #closable_bindings, 2 do + assert(_G["sym?"](closable_bindings[i]), "with-open only allows symbols in bindings") + table.insert(closer, 4, setmetatable({filename="src/fennel/macros.fnl", line=111, bytestart=3752, sym(':', nil, {quoted=true, filename="src/fennel/macros.fnl", line=111}), closable_bindings[i], "close"}, getmetatable(list()))) + end + return setmetatable({filename="src/fennel/macros.fnl", line=112, bytestart=3795, sym('let', nil, {quoted=true, filename="src/fennel/macros.fnl", line=112}), closable_bindings, closer, setmetatable({filename="src/fennel/macros.fnl", line=114, bytestart=3841, sym('close-handlers_12_', nil, {filename="src/fennel/macros.fnl", line=114}), setmetatable({filename="src/fennel/macros.fnl", line=114, bytestart=3858, sym('_G.xpcall', nil, {quoted=true, filename="src/fennel/macros.fnl", line=114}), bodyfn, traceback}, getmetatable(list()))}, getmetatable(list()))}, getmetatable(list())) + end + utils['fennel-module'].metadata:setall(with_open_2a, "fnl/arglist", {"closable-bindings", "..."}, "fnl/docstring", "Like `let`, but invokes (v:close) on each binding after evaluating the body.\nThe body is evaluated inside `xpcall` so that bound values will be closed upon\nencountering an error before propagating it.") + local function extract_into(iter_tbl) + local into, iter_out, found_3f = {}, copy(iter_tbl) + for i = #iter_tbl, 2, -1 do + local item = iter_tbl[i] + if (_G["sym?"](item, "&into") or ("into" == item)) then + assert(not found_3f, "expected only one &into clause") + found_3f = true + into = iter_tbl[(i + 1)] + table.remove(iter_out, i) + table.remove(iter_out, i) + end + end + assert((not found_3f or _G["sym?"](into) or _G["table?"](into) or _G["list?"](into)), "expected table, function call, or symbol in &into clause") + return into, iter_out, found_3f + end + utils['fennel-module'].metadata:setall(extract_into, "fnl/arglist", {"iter-tbl"}) + local function collect_2a(iter_tbl, key_expr, value_expr, ...) + assert((_G["sequence?"](iter_tbl) and (2 <= #iter_tbl)), "expected iterator binding table") + assert((nil ~= key_expr), "expected key and value expression") + assert((nil == ...), "expected 1 or 2 body expressions; wrap multiple expressions with do") + assert((value_expr or _G["list?"](key_expr)), "need key and value") + local kv_expr = nil + if (nil == value_expr) then + kv_expr = key_expr + else + kv_expr = setmetatable({filename="src/fennel/macros.fnl", line=151, bytestart=5514, sym('values', nil, {quoted=true, filename="src/fennel/macros.fnl", line=151}), key_expr, value_expr}, getmetatable(list())) + end + local into, iter = extract_into(iter_tbl) + return setmetatable({filename="src/fennel/macros.fnl", line=153, bytestart=5596, sym('let', nil, {quoted=true, filename="src/fennel/macros.fnl", line=153}), setmetatable({sym('tbl_16_', nil, {filename="src/fennel/macros.fnl", line=153}), into}, {filename="src/fennel/macros.fnl", line=153}), setmetatable({filename="src/fennel/macros.fnl", line=154, bytestart=5621, sym('each', nil, {quoted=true, filename="src/fennel/macros.fnl", line=154}), iter, setmetatable({filename="src/fennel/macros.fnl", line=155, bytestart=5642, sym('let', nil, {quoted=true, filename="src/fennel/macros.fnl", line=155}), setmetatable({setmetatable({filename="src/fennel/macros.fnl", line=155, bytestart=5648, sym('k_17_', nil, {filename="src/fennel/macros.fnl", line=155}), sym('v_18_', nil, {filename="src/fennel/macros.fnl", line=155})}, getmetatable(list())), kv_expr}, {filename="src/fennel/macros.fnl", line=155}), setmetatable({filename="src/fennel/macros.fnl", line=156, bytestart=5677, sym('if', nil, {quoted=true, filename="src/fennel/macros.fnl", line=156}), setmetatable({filename="src/fennel/macros.fnl", line=156, bytestart=5681, sym('and', nil, {quoted=true, filename="src/fennel/macros.fnl", line=156}), setmetatable({filename="src/fennel/macros.fnl", line=156, bytestart=5686, sym('not=', nil, {quoted=true, filename="src/fennel/macros.fnl", line=156}), sym('k_17_', nil, {filename="src/fennel/macros.fnl", line=156}), sym('nil', nil, {quoted=true, filename="src/fennel/macros.fnl", line=156})}, getmetatable(list())), setmetatable({filename="src/fennel/macros.fnl", line=156, bytestart=5700, sym('not=', nil, {quoted=true, filename="src/fennel/macros.fnl", line=156}), sym('v_18_', nil, {filename="src/fennel/macros.fnl", line=156}), sym('nil', nil, {quoted=true, filename="src/fennel/macros.fnl", line=156})}, getmetatable(list()))}, getmetatable(list())), setmetatable({filename="src/fennel/macros.fnl", line=157, bytestart=5728, sym('tset', nil, {quoted=true, filename="src/fennel/macros.fnl", line=157}), sym('tbl_16_', nil, {filename="src/fennel/macros.fnl", line=157}), sym('k_17_', nil, {filename="src/fennel/macros.fnl", line=157}), sym('v_18_', nil, {filename="src/fennel/macros.fnl", line=157})}, getmetatable(list()))}, getmetatable(list()))}, getmetatable(list()))}, getmetatable(list())), sym('tbl_16_', nil, {filename="src/fennel/macros.fnl", line=158})}, getmetatable(list())) + end + utils['fennel-module'].metadata:setall(collect_2a, "fnl/arglist", {"iter-tbl", "key-expr", "value-expr", "..."}, "fnl/docstring", "Return a table made by running an iterator and evaluating an expression that\nreturns key-value pairs to be inserted sequentially into the table. This can\nbe thought of as a table comprehension. The body should provide two expressions\n(used as key and value) or nil, which causes it to be omitted.\n\nFor example,\n (collect [k v (pairs {:apple \"red\" :orange \"orange\"})]\n (values v k))\nreturns\n {:red \"apple\" :orange \"orange\"}\n\nSupports an &into clause after the iterator to put results in an existing table.\nSupports early termination with an &until clause.") + local function seq_collect(how, iter_tbl, value_expr, ...) + assert((nil ~= value_expr), "expected table value expression") + assert((nil == ...), "expected exactly one body expression. Wrap multiple expressions in do") + local into, iter, has_into_3f = extract_into(iter_tbl) + if has_into_3f then + return setmetatable({filename="src/fennel/macros.fnl", line=170, bytestart=6252, sym('let', nil, {quoted=true, filename="src/fennel/macros.fnl", line=170}), setmetatable({sym('tbl_19_', nil, {filename="src/fennel/macros.fnl", line=170}), into}, {filename="src/fennel/macros.fnl", line=170}), setmetatable({filename="src/fennel/macros.fnl", line=171, bytestart=6281, how, iter, setmetatable({filename="src/fennel/macros.fnl", line=171, bytestart=6293, sym('let', nil, {quoted=true, filename="src/fennel/macros.fnl", line=171}), setmetatable({sym('val_20_', nil, {filename="src/fennel/macros.fnl", line=171}), value_expr}, {filename="src/fennel/macros.fnl", line=171}), setmetatable({filename="src/fennel/macros.fnl", line=172, bytestart=6342, sym('table.insert', nil, {quoted=true, filename="src/fennel/macros.fnl", line=172}), sym('tbl_19_', nil, {filename="src/fennel/macros.fnl", line=172}), sym('val_20_', nil, {filename="src/fennel/macros.fnl", line=172})}, getmetatable(list()))}, getmetatable(list()))}, getmetatable(list())), sym('tbl_19_', nil, {filename="src/fennel/macros.fnl", line=173})}, getmetatable(list())) + else + return setmetatable({filename="src/fennel/macros.fnl", line=177, bytestart=6618, sym('let', nil, {quoted=true, filename="src/fennel/macros.fnl", line=177}), setmetatable({sym('tbl_21_', nil, {filename="src/fennel/macros.fnl", line=177}), setmetatable({}, {filename="src/fennel/macros.fnl", line=177})}, {filename="src/fennel/macros.fnl", line=177}), setmetatable({filename="src/fennel/macros.fnl", line=178, bytestart=6644, sym('var', nil, {quoted=true, filename="src/fennel/macros.fnl", line=178}), sym('i_22_', nil, {filename="src/fennel/macros.fnl", line=178}), 0}, getmetatable(list())), setmetatable({filename="src/fennel/macros.fnl", line=179, bytestart=6666, how, iter, setmetatable({filename="src/fennel/macros.fnl", line=180, bytestart=6695, sym('let', nil, {quoted=true, filename="src/fennel/macros.fnl", line=180}), setmetatable({sym('val_23_', nil, {filename="src/fennel/macros.fnl", line=180}), value_expr}, {filename="src/fennel/macros.fnl", line=180}), setmetatable({filename="src/fennel/macros.fnl", line=181, bytestart=6738, sym('when', nil, {quoted=true, filename="src/fennel/macros.fnl", line=181}), setmetatable({filename="src/fennel/macros.fnl", line=181, bytestart=6744, sym('not=', nil, {quoted=true, filename="src/fennel/macros.fnl", line=181}), sym('nil', nil, {quoted=true, filename="src/fennel/macros.fnl", line=181}), sym('val_23_', nil, {filename="src/fennel/macros.fnl", line=181})}, getmetatable(list())), setmetatable({filename="src/fennel/macros.fnl", line=182, bytestart=6781, sym('set', nil, {quoted=true, filename="src/fennel/macros.fnl", line=182}), sym('i_22_', nil, {filename="src/fennel/macros.fnl", line=182}), setmetatable({filename="src/fennel/macros.fnl", line=182, bytestart=6789, sym('+', nil, {quoted=true, filename="src/fennel/macros.fnl", line=182}), sym('i_22_', nil, {filename="src/fennel/macros.fnl", line=182}), 1}, getmetatable(list()))}, getmetatable(list())), setmetatable({filename="src/fennel/macros.fnl", line=183, bytestart=6820, sym('tset', nil, {quoted=true, filename="src/fennel/macros.fnl", line=183}), sym('tbl_21_', nil, {filename="src/fennel/macros.fnl", line=183}), sym('i_22_', nil, {filename="src/fennel/macros.fnl", line=183}), sym('val_23_', nil, {filename="src/fennel/macros.fnl", line=183})}, getmetatable(list()))}, getmetatable(list()))}, getmetatable(list()))}, getmetatable(list())), sym('tbl_21_', nil, {filename="src/fennel/macros.fnl", line=184})}, getmetatable(list())) + end + end + utils['fennel-module'].metadata:setall(seq_collect, "fnl/arglist", {"how", "iter-tbl", "value-expr", "..."}, "fnl/docstring", "Common part between icollect and fcollect for producing sequential tables.\n\nIteration code only differs in using the for or each keyword, the rest\nof the generated code is identical.") + local function icollect_2a(iter_tbl, value_expr, ...) + assert((_G["sequence?"](iter_tbl) and (2 <= #iter_tbl)), "expected iterator binding table") + return seq_collect(sym('each', nil, {quoted=true, filename="src/fennel/macros.fnl", line=203}), iter_tbl, value_expr, ...) + end + utils['fennel-module'].metadata:setall(icollect_2a, "fnl/arglist", {"iter-tbl", "value-expr", "..."}, "fnl/docstring", "Return a sequential table made by running an iterator and evaluating an\nexpression that returns values to be inserted sequentially into the table.\nThis can be thought of as a table comprehension. If the body evaluates to nil\nthat element is omitted.\n\nFor example,\n (icollect [_ v (ipairs [1 2 3 4 5])]\n (when (not= v 3)\n (* v v)))\nreturns\n [1 4 16 25]\n\nSupports an &into clause after the iterator to put results in an existing table.\nSupports early termination with an &until clause.") + local function fcollect_2a(iter_tbl, value_expr, ...) + assert((_G["sequence?"](iter_tbl) and (2 < #iter_tbl)), "expected range binding table") + return seq_collect(sym('for', nil, {quoted=true, filename="src/fennel/macros.fnl", line=222}), iter_tbl, value_expr, ...) + end + utils['fennel-module'].metadata:setall(fcollect_2a, "fnl/arglist", {"iter-tbl", "value-expr", "..."}, "fnl/docstring", "Return a sequential table made by advancing a range as specified by\nfor, and evaluating an expression that returns values to be inserted\nsequentially into the table. This can be thought of as a range\ncomprehension. If the body evaluates to nil that element is omitted.\n\nFor example,\n (fcollect [i 1 10 2]\n (when (not= i 3)\n (* i i)))\nreturns\n [1 25 49 81]\n\nSupports an &into clause after the range to put results in an existing table.\nSupports early termination with an &until clause.") + local function accumulate_impl(for_3f, iter_tbl, body, ...) + assert((_G["sequence?"](iter_tbl) and (4 <= #iter_tbl)), "expected initial value and iterator binding table") + assert((nil ~= body), "expected body expression") + assert((nil == ...), "expected exactly one body expression. Wrap multiple expressions with do") + local _25_ = iter_tbl + local accum_var = _25_[1] + local accum_init = _25_[2] + local iter = nil + local function _26_(...) + if for_3f then + return "for" + else + return "each" + end + end + iter = sym(_26_(...)) + local function _27_(...) + if _G["list?"](accum_var) then + return list(sym("values"), unpack(accum_var)) + else + return accum_var + end + end + return setmetatable({filename="src/fennel/macros.fnl", line=232, bytestart=8695, sym('do', nil, {quoted=true, filename="src/fennel/macros.fnl", line=232}), setmetatable({filename="src/fennel/macros.fnl", line=233, bytestart=8706, sym('var', nil, {quoted=true, filename="src/fennel/macros.fnl", line=233}), accum_var, accum_init}, getmetatable(list())), setmetatable({filename="src/fennel/macros.fnl", line=234, bytestart=8742, iter, {unpack(iter_tbl, 3)}, setmetatable({filename="src/fennel/macros.fnl", line=235, bytestart=8786, sym('set', nil, {quoted=true, filename="src/fennel/macros.fnl", line=235}), accum_var, body}, getmetatable(list()))}, getmetatable(list())), _27_(...)}, getmetatable(list())) + end + utils['fennel-module'].metadata:setall(accumulate_impl, "fnl/arglist", {"for?", "iter-tbl", "body", "..."}) + local function accumulate_2a(iter_tbl, body, ...) + return accumulate_impl(false, iter_tbl, body, ...) + end + utils['fennel-module'].metadata:setall(accumulate_2a, "fnl/arglist", {"iter-tbl", "body", "..."}, "fnl/docstring", "Accumulation macro.\n\nIt takes a binding table and an expression as its arguments. In the binding\ntable, the first form starts out bound to the second value, which is an initial\naccumulator. The rest are an iterator binding table in the format `each` takes.\n\nIt runs through the iterator in each step of which the given expression is\nevaluated, and the accumulator is set to the value of the expression. It\neventually returns the final value of the accumulator.\n\nFor example,\n (accumulate [total 0\n _ n (pairs {:apple 2 :orange 3})]\n (+ total n))\nreturns 5") + local function faccumulate_2a(iter_tbl, body, ...) + return accumulate_impl(true, iter_tbl, body, ...) + end + utils['fennel-module'].metadata:setall(faccumulate_2a, "fnl/arglist", {"iter-tbl", "body", "..."}, "fnl/docstring", "Identical to accumulate, but after the accumulator the binding table is the\nsame as `for` instead of `each`. Like collect to fcollect, will iterate over a\nnumerical range like `for` rather than an iterator.") + local function partial_2a(f, ...) + assert(f, "expected a function to partially apply") + local bindings = {} + local args = {} + for _, arg in ipairs({...}) do + if utils["idempotent-expr?"](arg) then + table.insert(args, arg) + else + local name = gensym() + table.insert(bindings, name) + table.insert(bindings, arg) + table.insert(args, name) + end + end + local body = list(f, unpack(args)) + table.insert(body, _VARARG) + if (nil == bindings[1]) then + return setmetatable({filename="src/fennel/macros.fnl", line=280, bytestart=10477, sym('fn', nil, {quoted=true, filename="src/fennel/macros.fnl", line=280}), setmetatable({_VARARG}, {filename="src/fennel/macros.fnl", line=280}), body}, getmetatable(list())) + else + return setmetatable({filename="src/fennel/macros.fnl", line=281, bytestart=10510, sym('let', nil, {quoted=true, filename="src/fennel/macros.fnl", line=281}), bindings, setmetatable({filename="src/fennel/macros.fnl", line=282, bytestart=10538, sym('fn', nil, {quoted=true, filename="src/fennel/macros.fnl", line=282}), setmetatable({_VARARG}, {filename="src/fennel/macros.fnl", line=282}), body}, getmetatable(list()))}, getmetatable(list())) + end + end + utils['fennel-module'].metadata:setall(partial_2a, "fnl/arglist", {"f", "..."}, "fnl/docstring", "Return a function with all arguments partially applied to f.") + local function pick_args_2a(n, f) + if (_G.io and _G.io.stderr) then + do end (_G.io.stderr):write("-- WARNING: pick-args is deprecated and will be removed in the future.\n") + end + local bindings = {} + for i = 1, n do + bindings[i] = gensym() + end + return setmetatable({filename="src/fennel/macros.fnl", line=291, bytestart=10877, sym('fn', nil, {quoted=true, filename="src/fennel/macros.fnl", line=291}), bindings, setmetatable({filename="src/fennel/macros.fnl", line=291, bytestart=10891, f, unpack(bindings)}, getmetatable(list()))}, getmetatable(list())) + end + utils['fennel-module'].metadata:setall(pick_args_2a, "fnl/arglist", {"n", "f"}, "fnl/docstring", "Create a function of arity n that applies its arguments to f. Deprecated.") + local function lambda_2a(...) + local args = {...} + local args_len = #args + local has_internal_name_3f = _G["sym?"](args[1]) + local arglist = nil + if has_internal_name_3f then + arglist = args[2] + else + arglist = args[1] + end + local metadata_position = nil + if has_internal_name_3f then + metadata_position = 3 + else + metadata_position = 2 + end + local _, check_position = _G["get-function-metadata"]({"lambda", ...}, arglist, metadata_position) + local empty_body_3f = (args_len < check_position) + local function check_21(a) + if _G["table?"](a) then + for _0, a0 in pairs(a) do + check_21(a0) + end + return nil + else + local _33_ + do + local as = tostring(a) + local as1 = as:sub(1, 1) + _33_ = not (("_" == as1) or ("?" == as1) or ("&" == as) or ("..." == as) or ("&as" == as)) + end + if _33_ then + return table.insert(args, check_position, setmetatable({filename="src/fennel/macros.fnl", line=312, bytestart=11826, sym('_G.assert', nil, {quoted=true, filename="src/fennel/macros.fnl", line=312}), setmetatable({filename="src/fennel/macros.fnl", line=312, bytestart=11837, sym('not=', nil, {quoted=true, filename="src/fennel/macros.fnl", line=312}), sym('nil', nil, {quoted=true, filename="src/fennel/macros.fnl", line=312}), a}, getmetatable(list())), ("Missing argument %s on %s:%s"):format(tostring(a), (a.filename or "unknown"), (a.line or "?"))}, getmetatable(list()))) + end + end + end + utils['fennel-module'].metadata:setall(check_21, "fnl/arglist", {"a"}) + assert(("table" == type(arglist)), "expected arg list") + for _0, a in ipairs(arglist) do + check_21(a) + end + if empty_body_3f then + table.insert(args, sym("nil")) + end + return setmetatable({filename="src/fennel/macros.fnl", line=321, bytestart=12271, sym('fn', nil, {quoted=true, filename="src/fennel/macros.fnl", line=321}), unpack(args)}, getmetatable(list())) + end + utils['fennel-module'].metadata:setall(lambda_2a, "fnl/arglist", {"..."}, "fnl/docstring", "Function literal with nil-checked arguments.\nLike `fn`, but will throw an exception if a declared argument is passed in as\nnil, unless that argument's name begins with a question mark.") + local function macro_2a(name, ...) + assert(_G["sym?"](name), "expected symbol for macro name") + local args = {...} + return setmetatable({filename="src/fennel/macros.fnl", line=327, bytestart=12423, sym('macros', nil, {quoted=true, filename="src/fennel/macros.fnl", line=327}), setmetatable({[tostring(name)]=setmetatable({filename="src/fennel/macros.fnl", line=327, bytestart=12449, sym('fn', nil, {quoted=true, filename="src/fennel/macros.fnl", line=327}), unpack(args)}, getmetatable(list()))}, {filename="src/fennel/macros.fnl", line=327})}, getmetatable(list())) + end + utils['fennel-module'].metadata:setall(macro_2a, "fnl/arglist", {"name", "..."}, "fnl/docstring", "Define a single macro.") + local function macrodebug_2a(form, return_3f) + local handle = nil + if return_3f then + handle = sym('do', nil, {quoted=true, filename="src/fennel/macros.fnl", line=332}) + else + handle = sym('print', nil, {quoted=true, filename="src/fennel/macros.fnl", line=332}) + end + return setmetatable({filename="src/fennel/macros.fnl", line=335, bytestart=12845, handle, view(macroexpand(form, _SCOPE), {["detect-cycles?"] = false})}, getmetatable(list())) + end + utils['fennel-module'].metadata:setall(macrodebug_2a, "fnl/arglist", {"form", "return?"}, "fnl/docstring", "Print the resulting form after performing macroexpansion.\nWith a second argument, returns expanded form as a string instead of printing.") + local function import_macros_2a(binding1, module_name1, ...) + assert((binding1 and module_name1 and (0 == (select("#", ...) % 2))), "expected even number of binding/modulename pairs") + for i = 1, select("#", binding1, module_name1, ...), 2 do + local binding, modname = select(i, binding1, module_name1, ...) + local scope = _G["get-scope"]() + local expr = setmetatable({filename="src/fennel/macros.fnl", line=354, bytestart=14006, sym('import-macros', nil, {quoted=true, filename="src/fennel/macros.fnl", line=354}), modname}, getmetatable(list())) + local filename = nil + if _G["list?"](modname) then + filename = modname[1].filename + else + filename = "unknown" + end + local _ = nil + expr.filename = filename + _ = nil + local macros_2a = _SPECIALS["require-macros"](expr, scope, {}, binding) + if _G["sym?"](binding) then + scope.macros[binding[1]] = macros_2a + elseif _G["table?"](binding) then + for macro_name, _38_0 in pairs(binding) do + local _39_ = _38_0 + local import_key = _39_[1] + assert(("function" == type(macros_2a[macro_name])), ("macro " .. macro_name .. " not found in module " .. tostring(modname))) + scope.macros[import_key] = macros_2a[macro_name] + end + end + end + return nil + end + utils['fennel-module'].metadata:setall(import_macros_2a, "fnl/arglist", {"binding1", "module-name1", "..."}, "fnl/docstring", "Bind a table of macros from each macro module according to a binding form.\nEach binding form can be either a symbol or a k/v destructuring table.\nExample:\n (import-macros mymacros :my-macros ; bind to symbol\n {:macro1 alias : macro2} :proj.macros) ; import by name") + local function assert_repl_2a(condition, ...) + do local _ = {["fnl/arglist"] = {condition, _G["?message"], ...}} end + local function add_locals(_41_0, locals) + local _42_ = _41_0 + local parent = _42_["parent"] + local symmeta = _42_["symmeta"] + for name in pairs(symmeta) do + locals[name] = sym(name) + end + if parent then + return add_locals(parent, locals) + else + return locals + end + end + utils['fennel-module'].metadata:setall(add_locals, "fnl/arglist", {"#", "locals"}) + return setmetatable({filename="src/fennel/macros.fnl", line=379, bytestart=15225, sym('let', nil, {quoted=true, filename="src/fennel/macros.fnl", line=379}), setmetatable({sym('unpack_44_', nil, {filename="src/fennel/macros.fnl", line=379}), setmetatable({filename="src/fennel/macros.fnl", line=379, bytestart=15239, sym('or', nil, {quoted=true, filename="src/fennel/macros.fnl", line=379}), sym('table.unpack', nil, {quoted=true, filename="src/fennel/macros.fnl", line=379}), sym('_G.unpack', nil, {quoted=true, filename="src/fennel/macros.fnl", line=379})}, getmetatable(list())), sym('pack_46_', nil, {filename="src/fennel/macros.fnl", line=380}), setmetatable({filename="src/fennel/macros.fnl", line=380, bytestart=15282, sym('or', nil, {quoted=true, filename="src/fennel/macros.fnl", line=380}), sym('table.pack', nil, {quoted=true, filename="src/fennel/macros.fnl", line=380}), setmetatable({filename=nil, line=nil, bytestart=nil, sym('hashfn', nil, {quoted=true, filename=nil, line=nil}), setmetatable({filename="src/fennel/macros.fnl", line=380, bytestart=15298, sym('doto', nil, {quoted=true, filename="src/fennel/macros.fnl", line=380}), setmetatable({sym('$...', nil, {quoted=true, filename="src/fennel/macros.fnl", line=380})}, {filename="src/fennel/macros.fnl", line=380}), setmetatable({filename="src/fennel/macros.fnl", line=380, bytestart=15311, sym('tset', nil, {quoted=true, filename="src/fennel/macros.fnl", line=380}), "n", setmetatable({filename="src/fennel/macros.fnl", line=380, bytestart=15320, sym('select', nil, {quoted=true, filename="src/fennel/macros.fnl", line=380}), "#", sym('$...', nil, {quoted=true, filename="src/fennel/macros.fnl", line=380})}, getmetatable(list()))}, getmetatable(list()))}, getmetatable(list()))}, getmetatable(list()))}, getmetatable(list())), sym('vals_45_', nil, {filename="src/fennel/macros.fnl", line=383}), setmetatable({filename="src/fennel/macros.fnl", line=383, bytestart=15493, sym('pack_46_', nil, {filename="src/fennel/macros.fnl", line=383}), condition, ...}, getmetatable(list())), sym('condition_47_', nil, {filename="src/fennel/macros.fnl", line=384}), setmetatable({filename="src/fennel/macros.fnl", line=384, bytestart=15537, sym('.', nil, {quoted=true, filename="src/fennel/macros.fnl", line=384}), sym('vals_45_', nil, {filename="src/fennel/macros.fnl", line=384}), 1}, getmetatable(list())), sym('message_48_', nil, {filename="src/fennel/macros.fnl", line=385}), setmetatable({filename="src/fennel/macros.fnl", line=385, bytestart=15567, sym('or', nil, {quoted=true, filename="src/fennel/macros.fnl", line=385}), setmetatable({filename="src/fennel/macros.fnl", line=385, bytestart=15571, sym('.', nil, {quoted=true, filename="src/fennel/macros.fnl", line=385}), sym('vals_45_', nil, {filename="src/fennel/macros.fnl", line=385}), 2}, getmetatable(list())), "assertion failed, entering repl."}, getmetatable(list()))}, {filename="src/fennel/macros.fnl", line=379}), setmetatable({filename="src/fennel/macros.fnl", line=386, bytestart=15625, sym('if', nil, {quoted=true, filename="src/fennel/macros.fnl", line=386}), setmetatable({filename="src/fennel/macros.fnl", line=386, bytestart=15629, sym('not', nil, {quoted=true, filename="src/fennel/macros.fnl", line=386}), sym('condition_47_', nil, {filename="src/fennel/macros.fnl", line=386})}, getmetatable(list())), setmetatable({filename="src/fennel/macros.fnl", line=387, bytestart=15655, sym('let', nil, {quoted=true, filename="src/fennel/macros.fnl", line=387}), setmetatable({sym('opts_49_', nil, {filename="src/fennel/macros.fnl", line=387}), setmetatable({["assert-repl?"]=true}, {filename="src/fennel/macros.fnl", line=387}), sym('fennel_50_', nil, {filename="src/fennel/macros.fnl", line=388}), setmetatable({filename="src/fennel/macros.fnl", line=388, bytestart=15711, sym('require', nil, {quoted=true, filename="src/fennel/macros.fnl", line=388}), _G["fennel-module-name"]()}, getmetatable(list())), sym('locals_51_', nil, {filename="src/fennel/macros.fnl", line=389}), add_locals(_G["get-scope"](), {})}, {filename="src/fennel/macros.fnl", line=387}), setmetatable({filename="src/fennel/macros.fnl", line=390, bytestart=15807, sym('set', nil, {quoted=true, filename="src/fennel/macros.fnl", line=390}), sym('opts_49_.message', nil, {filename="src/fennel/macros.fnl", line=390}), setmetatable({filename="src/fennel/macros.fnl", line=390, bytestart=15826, sym('fennel_50_.traceback', nil, {filename="src/fennel/macros.fnl", line=390}), sym('message_48_', nil, {filename="src/fennel/macros.fnl", line=390})}, getmetatable(list()))}, getmetatable(list())), setmetatable({filename="src/fennel/macros.fnl", line=391, bytestart=15867, sym('each', nil, {quoted=true, filename="src/fennel/macros.fnl", line=391}), setmetatable({sym('k_52_', nil, {filename="src/fennel/macros.fnl", line=391}), sym('v_53_', nil, {filename="src/fennel/macros.fnl", line=391}), setmetatable({filename="src/fennel/macros.fnl", line=391, bytestart=15880, sym('pairs', nil, {quoted=true, filename="src/fennel/macros.fnl", line=391}), sym('_G', nil, {quoted=true, filename="src/fennel/macros.fnl", line=391})}, getmetatable(list()))}, {filename="src/fennel/macros.fnl", line=391}), setmetatable({filename="src/fennel/macros.fnl", line=392, bytestart=15905, sym('when', nil, {quoted=true, filename="src/fennel/macros.fnl", line=392}), setmetatable({filename="src/fennel/macros.fnl", line=392, bytestart=15911, sym('=', nil, {quoted=true, filename="src/fennel/macros.fnl", line=392}), sym('nil', nil, {quoted=true, filename="src/fennel/macros.fnl", line=392}), setmetatable({filename="src/fennel/macros.fnl", line=392, bytestart=15918, sym('.', nil, {quoted=true, filename="src/fennel/macros.fnl", line=392}), sym('locals_51_', nil, {filename="src/fennel/macros.fnl", line=392}), sym('k_52_', nil, {filename="src/fennel/macros.fnl", line=392})}, getmetatable(list()))}, getmetatable(list())), setmetatable({filename="src/fennel/macros.fnl", line=392, bytestart=15934, sym('tset', nil, {quoted=true, filename="src/fennel/macros.fnl", line=392}), sym('locals_51_', nil, {filename="src/fennel/macros.fnl", line=392}), sym('k_52_', nil, {filename="src/fennel/macros.fnl", line=392}), sym('v_53_', nil, {filename="src/fennel/macros.fnl", line=392})}, getmetatable(list()))}, getmetatable(list()))}, getmetatable(list())), setmetatable({filename="src/fennel/macros.fnl", line=393, bytestart=15968, sym('set', nil, {quoted=true, filename="src/fennel/macros.fnl", line=393}), sym('opts_49_.env', nil, {filename="src/fennel/macros.fnl", line=393}), sym('locals_51_', nil, {filename="src/fennel/macros.fnl", line=393})}, getmetatable(list())), setmetatable({filename="src/fennel/macros.fnl", line=394, bytestart=16003, sym('_G.assert', nil, {quoted=true, filename="src/fennel/macros.fnl", line=394}), setmetatable({filename="src/fennel/macros.fnl", line=394, bytestart=16014, sym('fennel_50_.repl', nil, {filename="src/fennel/macros.fnl", line=394}), sym('opts_49_', nil, {filename="src/fennel/macros.fnl", line=394})}, getmetatable(list()))}, getmetatable(list()))}, getmetatable(list())), setmetatable({filename="src/fennel/macros.fnl", line=395, bytestart=16046, sym('values', nil, {quoted=true, filename="src/fennel/macros.fnl", line=395}), setmetatable({filename="src/fennel/macros.fnl", line=395, bytestart=16054, sym('unpack_44_', nil, {filename="src/fennel/macros.fnl", line=395}), sym('vals_45_', nil, {filename="src/fennel/macros.fnl", line=395}), 1, sym('vals_45_.n', nil, {filename="src/fennel/macros.fnl", line=395})}, getmetatable(list()))}, getmetatable(list()))}, getmetatable(list()))}, getmetatable(list())) + end + utils['fennel-module'].metadata:setall(assert_repl_2a, "fnl/arglist", {"condition", "..."}, "fnl/docstring", "Enter into a debug REPL and print the message when condition is false/nil.\nWorks as a drop-in replacement for Lua's `assert`.\nREPL `,return` command returns values to assert in place to continue execution.") + return {["->"] = __3e_2a, ["->>"] = __3e_3e_2a, ["-?>"] = __3f_3e_2a, ["-?>>"] = __3f_3e_3e_2a, ["?."] = _3fdot, ["\206\187"] = lambda_2a, ["assert-repl"] = assert_repl_2a, ["import-macros"] = import_macros_2a, ["pick-args"] = pick_args_2a, ["with-open"] = with_open_2a, accumulate = accumulate_2a, collect = collect_2a, doto = doto_2a, faccumulate = faccumulate_2a, fcollect = fcollect_2a, icollect = icollect_2a, lambda = lambda_2a, macro = macro_2a, macrodebug = macrodebug_2a, partial = partial_2a, when = when_2a} + ]===], env) + load_macros([===[local function copy(t) + local tbl_14_ = {} + for k, v in pairs(t) do + local k_15_, v_16_ = k, v + if ((k_15_ ~= nil) and (v_16_ ~= nil)) then + tbl_14_[k_15_] = v_16_ + end + end + return tbl_14_ + end + utils['fennel-module'].metadata:setall(copy, "fnl/arglist", {"t"}) + local function double_eval_safe_3f(x, type) + return (("number" == type) or ("string" == type) or ("boolean" == type) or (_G["sym?"](x) and not _G["multi-sym?"](x))) + end + utils['fennel-module'].metadata:setall(double_eval_safe_3f, "fnl/arglist", {"x", "type"}) + local function with(opts, k) + local _2_0 = copy(opts) + _2_0[k] = true + return _2_0 + end + utils['fennel-module'].metadata:setall(with, "fnl/arglist", {"opts", "k"}) + local function without(opts, k) + local _3_0 = copy(opts) + _3_0[k] = nil + return _3_0 + end + utils['fennel-module'].metadata:setall(without, "fnl/arglist", {"opts", "k"}) + local function case_values(vals, pattern, unifications, case_pattern, opts) + local condition = setmetatable({filename="src/fennel/match.fnl", line=20, bytestart=528, sym('and', nil, {quoted=true, filename="src/fennel/match.fnl", line=20})}, getmetatable(list())) + local bindings = {} + for i, pat in ipairs(pattern) do + local subcondition, subbindings = case_pattern({vals[i]}, pat, unifications, without(opts, "multival?")) + table.insert(condition, subcondition) + local tbl_17_ = bindings + local i_18_ = #tbl_17_ + for _, b in ipairs(subbindings) do + local val_19_ = b + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + end + return condition, bindings + end + utils['fennel-module'].metadata:setall(case_values, "fnl/arglist", {"vals", "pattern", "unifications", "case-pattern", "opts"}) + local function case_table(val, pattern, unifications, case_pattern, opts, _3ftop) + local condition = nil + if ("table" == _3ftop) then + condition = setmetatable({filename="src/fennel/match.fnl", line=30, bytestart=1005, sym('and', nil, {quoted=true, filename="src/fennel/match.fnl", line=30})}, getmetatable(list())) + else + condition = setmetatable({filename="src/fennel/match.fnl", line=30, bytestart=1012, sym('and', nil, {quoted=true, filename="src/fennel/match.fnl", line=30}), setmetatable({filename="src/fennel/match.fnl", line=30, bytestart=1017, sym('=', nil, {quoted=true, filename="src/fennel/match.fnl", line=30}), setmetatable({filename="src/fennel/match.fnl", line=30, bytestart=1020, sym('_G.type', nil, {quoted=true, filename="src/fennel/match.fnl", line=30}), val}, getmetatable(list())), "table"}, getmetatable(list()))}, getmetatable(list())) + end + local bindings = {} + for k, pat in pairs(pattern) do + if _G["sym?"](pat, "&") then + local rest_pat = pattern[(k + 1)] + local rest_val = setmetatable({filename="src/fennel/match.fnl", line=35, bytestart=1195, sym('select', nil, {quoted=true, filename="src/fennel/match.fnl", line=35}), k, setmetatable({filename="src/fennel/match.fnl", line=35, bytestart=1206, setmetatable({filename="src/fennel/match.fnl", line=35, bytestart=1207, sym('or', nil, {quoted=true, filename="src/fennel/match.fnl", line=35}), sym('table.unpack', nil, {quoted=true, filename="src/fennel/match.fnl", line=35}), sym('_G.unpack', nil, {quoted=true, filename="src/fennel/match.fnl", line=35})}, getmetatable(list())), val}, getmetatable(list()))}, getmetatable(list())) + local subcondition = case_table(setmetatable({filename="src/fennel/match.fnl", line=36, bytestart=1284, sym('pick-values', nil, {quoted=true, filename="src/fennel/match.fnl", line=36}), 1, rest_val}, getmetatable(list())), rest_pat, unifications, case_pattern, without(opts, "multival?")) + if not _G["sym?"](rest_pat) then + table.insert(condition, subcondition) + end + assert((nil == pattern[(k + 2)]), "expected & rest argument before last parameter") + table.insert(bindings, rest_pat) + table.insert(bindings, {rest_val}) + elseif _G["sym?"](k, "&as") then + table.insert(bindings, pat) + table.insert(bindings, val) + elseif (("number" == type(k)) and _G["sym?"](pat, "&as")) then + assert((nil == pattern[(k + 2)]), "expected &as argument before last parameter") + table.insert(bindings, pattern[(k + 1)]) + table.insert(bindings, val) + elseif (("number" ~= type(k)) or (not _G["sym?"](pattern[(k - 1)], "&as") and not _G["sym?"](pattern[(k - 1)], "&"))) then + local subval = setmetatable({filename="src/fennel/match.fnl", line=58, bytestart=2418, sym('.', nil, {quoted=true, filename="src/fennel/match.fnl", line=58}), val, k}, getmetatable(list())) + local subcondition, subbindings = case_pattern({subval}, pat, unifications, without(opts, "multival?")) + table.insert(condition, subcondition) + local tbl_17_ = bindings + local i_18_ = #tbl_17_ + for _, b in ipairs(subbindings) do + local val_19_ = b + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + end + end + return condition, bindings + end + utils['fennel-module'].metadata:setall(case_table, "fnl/arglist", {"val", "pattern", "unifications", "case-pattern", "opts", "?top"}) + local function case_guard(vals, condition, guards, unifications, case_pattern, opts) + if guards[1] then + local pcondition, bindings = case_pattern(vals, condition, unifications, opts) + local condition0 = setmetatable({filename="src/fennel/match.fnl", line=69, bytestart=3002, sym('and', nil, {quoted=true, filename="src/fennel/match.fnl", line=69}), unpack(guards)}, getmetatable(list())) + return setmetatable({filename="src/fennel/match.fnl", line=70, bytestart=3042, sym('and', nil, {quoted=true, filename="src/fennel/match.fnl", line=70}), pcondition, setmetatable({filename="src/fennel/match.fnl", line=71, bytestart=3080, sym('let', nil, {quoted=true, filename="src/fennel/match.fnl", line=71}), bindings, condition0}, getmetatable(list()))}, getmetatable(list())), bindings + else + return case_pattern(vals, condition, unifications, opts) + end + end + utils['fennel-module'].metadata:setall(case_guard, "fnl/arglist", {"vals", "condition", "guards", "unifications", "case-pattern", "opts"}) + local function symbols_in_pattern(pattern) + if _G["list?"](pattern) then + if (_G["sym?"](pattern[1], "where") or _G["sym?"](pattern[1], "=")) then + return symbols_in_pattern(pattern[2]) + elseif _G["sym?"](pattern[2], "?") then + return symbols_in_pattern(pattern[1]) + else + local result = {} + for _, child_pattern in ipairs(pattern) do + local tbl_14_ = result + for name, symbol in pairs(symbols_in_pattern(child_pattern)) do + local k_15_, v_16_ = name, symbol + if ((k_15_ ~= nil) and (v_16_ ~= nil)) then + tbl_14_[k_15_] = v_16_ + end + end + end + return result + end + elseif _G["sym?"](pattern) then + if (not _G["sym?"](pattern, "or") and not _G["sym?"](pattern, "nil")) then + return {[tostring(pattern)] = pattern} + else + return {} + end + elseif (type(pattern) == "table") then + local result = {} + for key_pattern, value_pattern in pairs(pattern) do + do + local tbl_14_ = result + for name, symbol in pairs(symbols_in_pattern(key_pattern)) do + local k_15_, v_16_ = name, symbol + if ((k_15_ ~= nil) and (v_16_ ~= nil)) then + tbl_14_[k_15_] = v_16_ + end + end + end + local tbl_14_ = result + for name, symbol in pairs(symbols_in_pattern(value_pattern)) do + local k_15_, v_16_ = name, symbol + if ((k_15_ ~= nil) and (v_16_ ~= nil)) then + tbl_14_[k_15_] = v_16_ + end + end + end + return result + else + return {} + end + end + utils['fennel-module'].metadata:setall(symbols_in_pattern, "fnl/arglist", {"pattern"}, "fnl/docstring", "gives the set of symbols inside a pattern") + local function symbols_in_every_pattern(pattern_list, infer_unification_3f) + local _3fsymbols = nil + do + local _3fsymbols0 = nil + for _, pattern in ipairs(pattern_list) do + local in_pattern = symbols_in_pattern(pattern) + if _3fsymbols0 then + for name in pairs(_3fsymbols0) do + if not in_pattern[name] then + _3fsymbols0[name] = nil + end + end + _3fsymbols0 = _3fsymbols0 + else + _3fsymbols0 = in_pattern + end + end + _3fsymbols = _3fsymbols0 + end + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for _, symbol in pairs((_3fsymbols or {})) do + local val_19_ = nil + if not (infer_unification_3f and _G["in-scope?"](symbol)) then + val_19_ = symbol + else + val_19_ = nil + end + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + return tbl_17_ + end + utils['fennel-module'].metadata:setall(symbols_in_every_pattern, "fnl/arglist", {"pattern-list", "infer-unification?"}, "fnl/docstring", "gives a list of symbols that are present in every pattern in the list") + local function case_or(vals, pattern, guards, unifications, case_pattern, opts) + local pattern0 = {unpack(pattern, 2)} + local bindings = symbols_in_every_pattern(pattern0, opts["infer-unification?"]) + if (nil == bindings[1]) then + local condition = nil + do + local tbl_17_ = setmetatable({filename="src/fennel/match.fnl", line=125, bytestart=5354, sym('or', nil, {quoted=true, filename="src/fennel/match.fnl", line=125})}, getmetatable(list())) + local i_18_ = #tbl_17_ + for _, subpattern in ipairs(pattern0) do + local val_19_ = case_pattern(vals, subpattern, unifications, opts) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + condition = tbl_17_ + end + local _21_ + if guards[1] then + _21_ = setmetatable({filename="src/fennel/match.fnl", line=128, bytestart=5495, sym('and', nil, {quoted=true, filename="src/fennel/match.fnl", line=128}), condition, unpack(guards)}, getmetatable(list())) + else + _21_ = condition + end + return _21_, {} + else + local matched_3f = gensym("matched?") + local bindings_mangled = nil + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for _, binding in ipairs(bindings) do + local val_19_ = gensym(tostring(binding)) + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + bindings_mangled = tbl_17_ + end + local pre_bindings = setmetatable({filename="src/fennel/match.fnl", line=135, bytestart=5870, sym('if', nil, {quoted=true, filename="src/fennel/match.fnl", line=135})}, getmetatable(list())) + for _, subpattern in ipairs(pattern0) do + local subcondition, subbindings = case_guard(vals, subpattern, guards, {}, case_pattern, opts) + table.insert(pre_bindings, subcondition) + table.insert(pre_bindings, setmetatable({filename="src/fennel/match.fnl", line=139, bytestart=6116, sym('let', nil, {quoted=true, filename="src/fennel/match.fnl", line=139}), subbindings, setmetatable({filename="src/fennel/match.fnl", line=140, bytestart=6176, sym('values', nil, {quoted=true, filename="src/fennel/match.fnl", line=140}), true, unpack(bindings)}, getmetatable(list()))}, getmetatable(list()))) + end + return matched_3f, {setmetatable({filename="src/fennel/match.fnl", line=142, bytestart=6256, unpack(bindings)}, getmetatable(list())), setmetatable({filename="src/fennel/match.fnl", line=142, bytestart=6278, sym('values', nil, {quoted=true, filename="src/fennel/match.fnl", line=142}), unpack(bindings_mangled)}, getmetatable(list()))}, {setmetatable({filename="src/fennel/match.fnl", line=143, bytestart=6333, matched_3f, unpack(bindings_mangled)}, getmetatable(list())), pre_bindings} + end + end + utils['fennel-module'].metadata:setall(case_or, "fnl/arglist", {"vals", "pattern", "guards", "unifications", "case-pattern", "opts"}) + local function case_pattern(vals, pattern, unifications, opts, _3ftop) + local _25_ = vals + local val = _25_[1] + if (_G["sym?"](pattern) and (_G["sym?"](pattern, "nil") or (opts["infer-unification?"] and _G["in-scope?"](pattern) and not _G["sym?"](pattern, "_")) or (opts["infer-unification?"] and _G["multi-sym?"](pattern) and _G["in-scope?"](_G["multi-sym?"](pattern)[1])))) then + return setmetatable({filename="src/fennel/match.fnl", line=177, bytestart=8254, sym('=', nil, {quoted=true, filename="src/fennel/match.fnl", line=177}), val, pattern}, getmetatable(list())), {} + elseif (_G["sym?"](pattern) and unifications[tostring(pattern)]) then + return setmetatable({filename="src/fennel/match.fnl", line=180, bytestart=8402, sym('=', nil, {quoted=true, filename="src/fennel/match.fnl", line=180}), unifications[tostring(pattern)], val}, getmetatable(list())), {} + elseif _G["sym?"](pattern) then + local wildcard_3f = tostring(pattern):find("^_") + if not wildcard_3f then + unifications[tostring(pattern)] = val + end + local _27_ + if (wildcard_3f or string.find(tostring(pattern), "^?")) then + _27_ = true + else + _27_ = setmetatable({filename="src/fennel/match.fnl", line=186, bytestart=8741, sym('not=', nil, {quoted=true, filename="src/fennel/match.fnl", line=186}), sym("nil"), val}, getmetatable(list())) + end + return _27_, {pattern, val} + elseif (_G["list?"](pattern) and _G["sym?"](pattern[1], "=") and _G["sym?"](pattern[2])) then + local bind = pattern[2] + _G["assert-compile"]((2 == #pattern), "(=) should take only one argument", pattern) + _G["assert-compile"](not opts["infer-unification?"], "(=) cannot be used inside of match", pattern) + _G["assert-compile"](opts["in-where?"], "(=) must be used in (where) patterns", pattern) + _G["assert-compile"]((_G["sym?"](bind) and not _G["sym?"](bind, "nil") and "= has to bind to a symbol" and bind)) + return setmetatable({filename="src/fennel/match.fnl", line=196, bytestart=9355, sym('=', nil, {quoted=true, filename="src/fennel/match.fnl", line=196}), val, bind}, getmetatable(list())), {} + elseif (_G["list?"](pattern) and _G["sym?"](pattern[1], "where") and _G["list?"](pattern[2]) and _G["sym?"](pattern[2][1], "or")) then + _G["assert-compile"](_3ftop, "can't nest (where) pattern", pattern) + return case_or(vals, pattern[2], {unpack(pattern, 3)}, unifications, case_pattern, with(opts, "in-where?")) + elseif (_G["list?"](pattern) and _G["sym?"](pattern[1], "where")) then + _G["assert-compile"](_3ftop, "can't nest (where) pattern", pattern) + return case_guard(vals, pattern[2], {unpack(pattern, 3)}, unifications, case_pattern, with(opts, "in-where?")) + elseif (_G["list?"](pattern) and _G["sym?"](pattern[1], "or")) then + _G["assert-compile"](_3ftop, "can't nest (or) pattern", pattern) + _G["assert-compile"](false, "(or) must be used in (where) patterns", pattern) + return case_or(vals, pattern, {}, unifications, case_pattern, opts) + elseif (_G["list?"](pattern) and _G["sym?"](pattern[2], "?")) then + _G["assert-compile"](opts["legacy-guard-allowed?"], "legacy guard clause not supported in case", pattern) + return case_guard(vals, pattern[1], {unpack(pattern, 3)}, unifications, case_pattern, opts) + elseif _G["list?"](pattern) then + _G["assert-compile"](opts["multival?"], "can't nest multi-value destructuring", pattern) + return case_values(vals, pattern, unifications, case_pattern, opts) + elseif (type(pattern) == "table") then + return case_table(val, pattern, unifications, case_pattern, opts, _3ftop) + else + return setmetatable({filename="src/fennel/match.fnl", line=228, bytestart=11092, sym('=', nil, {quoted=true, filename="src/fennel/match.fnl", line=228}), val, pattern}, getmetatable(list())), {} + end + end + utils['fennel-module'].metadata:setall(case_pattern, "fnl/arglist", {"vals", "pattern", "unifications", "opts", "?top"}, "fnl/docstring", "Take the AST of values and a single pattern and returns a condition\nto determine if it matches as well as a list of bindings to\nintroduce for the duration of the body if it does match.") + local function add_pre_bindings(out, pre_bindings) + if pre_bindings then + local tail = setmetatable({filename="src/fennel/match.fnl", line=237, bytestart=11490, sym('if', nil, {quoted=true, filename="src/fennel/match.fnl", line=237})}, getmetatable(list())) + table.insert(out, true) + table.insert(out, setmetatable({filename="src/fennel/match.fnl", line=239, bytestart=11555, sym('let', nil, {quoted=true, filename="src/fennel/match.fnl", line=239}), pre_bindings, tail}, getmetatable(list()))) + return tail + else + return out + end + end + utils['fennel-module'].metadata:setall(add_pre_bindings, "fnl/arglist", {"out", "pre-bindings"}, "fnl/docstring", "Decide when to switch from the current `if` AST to a new one") + local function case_condition(vals, clauses, match_3f, top_table_3f) + local root = setmetatable({filename="src/fennel/match.fnl", line=248, bytestart=11896, sym('if', nil, {quoted=true, filename="src/fennel/match.fnl", line=248})}, getmetatable(list())) + do + local out = root + for i = 1, #clauses, 2 do + local pattern = clauses[i] + local body = clauses[(i + 1)] + local condition, bindings, pre_bindings = nil, nil, nil + local function _31_() + if top_table_3f then + return "table" + else + return true + end + end + condition, bindings, pre_bindings = case_pattern(vals, pattern, {}, {["infer-unification?"] = match_3f, ["legacy-guard-allowed?"] = match_3f, ["multival?"] = true}, _31_()) + local out0 = add_pre_bindings(out, pre_bindings) + table.insert(out0, condition) + table.insert(out0, setmetatable({filename="src/fennel/match.fnl", line=261, bytestart=12633, sym('let', nil, {quoted=true, filename="src/fennel/match.fnl", line=261}), bindings, body}, getmetatable(list()))) + out = out0 + end + end + return root + end + utils['fennel-module'].metadata:setall(case_condition, "fnl/arglist", {"vals", "clauses", "match?", "top-table?"}, "fnl/docstring", "Construct the actual `if` AST for the given match values and clauses.") + local function count_case_multival(pattern) + if (_G["list?"](pattern) and _G["sym?"](pattern[2], "?")) then + return count_case_multival(pattern[1]) + elseif (_G["list?"](pattern) and _G["sym?"](pattern[1], "where")) then + return count_case_multival(pattern[2]) + elseif (_G["list?"](pattern) and _G["sym?"](pattern[1], "or")) then + local longest = 0 + for _, child_pattern in ipairs(pattern) do + longest = math.max(longest, count_case_multival(child_pattern)) + end + return longest + elseif _G["list?"](pattern) then + return #pattern + else + return 1 + end + end + utils['fennel-module'].metadata:setall(count_case_multival, "fnl/arglist", {"pattern"}, "fnl/docstring", "Identify the amount of multival values that a pattern requires.") + local function case_count_syms(clauses) + local patterns = nil + do + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for i = 1, #clauses, 2 do + local val_19_ = clauses[i] + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + patterns = tbl_17_ + end + local longest = 0 + for _, pattern in ipairs(patterns) do + longest = math.max(longest, count_case_multival(pattern)) + end + return longest + end + utils['fennel-module'].metadata:setall(case_count_syms, "fnl/arglist", {"clauses"}, "fnl/docstring", "Find the length of the largest multi-valued clause") + local function maybe_optimize_table(val, clauses) + local _34_ + do + local all = _G["sequence?"](val) + for i = 1, #clauses, 2 do + if not all then break end + local function _35_() + local all2 = next(clauses[i]) + for _, d in ipairs(clauses[i]) do + if not all2 then break end + all2 = (all2 and (not _G["sym?"](d) or not tostring(d):find("^&"))) + end + return all2 + end + all = (_G["sequence?"](clauses[i]) and _35_()) + end + _34_ = all + end + if _34_ then + local function _36_() + local tbl_17_ = {} + local i_18_ = #tbl_17_ + for i = 1, #clauses do + local val_19_ = nil + if (1 == (i % 2)) then + val_19_ = list(unpack(clauses[i])) + else + val_19_ = clauses[i] + end + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + return tbl_17_ + end + return setmetatable({filename="src/fennel/match.fnl", line=293, bytestart=13916, sym('values', nil, {quoted=true, filename="src/fennel/match.fnl", line=293}), unpack(val)}, getmetatable(list())), _36_() + else + return val, clauses + end + end + utils['fennel-module'].metadata:setall(maybe_optimize_table, "fnl/arglist", {"val", "clauses"}) + local function case_impl(match_3f, init_val, ...) + assert((init_val ~= nil), "missing subject") + assert((0 == math.fmod(select("#", ...), 2)), "expected even number of pattern/body pairs") + assert((0 ~= select("#", ...)), "expected at least one pattern/body pair") + local val, clauses = maybe_optimize_table(init_val, {...}) + local vals_count = case_count_syms(clauses) + local skips_multiple_eval_protection_3f = ((vals_count == 1) and double_eval_safe_3f(val)) + if skips_multiple_eval_protection_3f then + return case_condition(list(val), clauses, match_3f, _G["table?"](init_val)) + else + local vals = nil + do + local tbl_17_ = list() + local i_18_ = #tbl_17_ + for _ = 1, vals_count do + local val_19_ = gensym() + if (nil ~= val_19_) then + i_18_ = (i_18_ + 1) + tbl_17_[i_18_] = val_19_ + end + end + vals = tbl_17_ + end + return list(sym('let', nil, {quoted=true, filename="src/fennel/match.fnl", line=315}), {vals, val}, case_condition(vals, clauses, match_3f, _G["table?"](init_val))) + end + end + utils['fennel-module'].metadata:setall(case_impl, "fnl/arglist", {"match?", "init-val", "..."}, "fnl/docstring", "The shared implementation of case and match.") + local function case_2a(val, ...) + return case_impl(false, val, ...) + end + utils['fennel-module'].metadata:setall(case_2a, "fnl/arglist", {"val", "..."}, "fnl/docstring", "Perform pattern matching on val. See reference for details.\n\nSyntax:\n\n(case data-expression\n pattern body\n (where pattern guards*) body\n (where (or pattern patterns*) guards*) body)") + local function match_2a(val, ...) + return case_impl(true, val, ...) + end + utils['fennel-module'].metadata:setall(match_2a, "fnl/arglist", {"val", "..."}, "fnl/docstring", "Perform pattern matching on val, automatically unifying on variables in\nlocal scope. See reference for details.\n\nSyntax:\n\n(match data-expression\n pattern body\n (where pattern guards*) body\n (where (or pattern patterns*) guards*) body)") + local function case_try_step(how, expr, _else, pattern, body, ...) + if ((nil == pattern) and (pattern == body)) then + return expr + else + return setmetatable({filename="src/fennel/match.fnl", line=346, bytestart=15867, setmetatable({filename="src/fennel/match.fnl", line=346, bytestart=15868, sym('fn', nil, {quoted=true, filename="src/fennel/match.fnl", line=346}), setmetatable({_VARARG}, {filename="src/fennel/match.fnl", line=346}), setmetatable({filename="src/fennel/match.fnl", line=347, bytestart=15888, how, _VARARG, pattern, case_try_step(how, body, _else, ...), unpack(_else)}, getmetatable(list()))}, getmetatable(list())), expr}, getmetatable(list())) + end + end + utils['fennel-module'].metadata:setall(case_try_step, "fnl/arglist", {"how", "expr", "else", "pattern", "body", "..."}) + local function case_try_impl(how, expr, pattern, body, ...) + local clauses = {pattern, body, ...} + local last = clauses[#clauses] + local catch = nil + if _G["sym?"]((("table" == type(last)) and last[1]), "catch") then + local _43_ = table.remove(clauses) + local _ = _43_[1] + local e = {(table.unpack or unpack)(_43_, 2)} + catch = e + else + catch = {sym('__44_', nil, {filename="src/fennel/match.fnl", line=357}), _VARARG} + end + assert((0 == math.fmod(#clauses, 2)), "expected every pattern to have a body") + assert((0 == math.fmod(#catch, 2)), "expected every catch pattern to have a body") + return case_try_step(how, expr, catch, unpack(clauses)) + end + utils['fennel-module'].metadata:setall(case_try_impl, "fnl/arglist", {"how", "expr", "pattern", "body", "..."}) + local function case_try_2a(expr, pattern, body, ...) + return case_try_impl(sym('case', nil, {quoted=true, filename="src/fennel/match.fnl", line=375}), expr, pattern, body, ...) + end + utils['fennel-module'].metadata:setall(case_try_2a, "fnl/arglist", {"expr", "pattern", "body", "..."}, "fnl/docstring", "Perform chained pattern matching for a sequence of steps which might fail.\n\nThe values from the initial expression are matched against the first pattern.\nIf they match, the first body is evaluated and its values are matched against\nthe second pattern, etc.\n\nIf there is a (catch pat1 body1 pat2 body2 ...) form at the end, any mismatch\nfrom the steps will be tried against these patterns in sequence as a fallback\njust like a normal match. If there is no catch, the mismatched values will be\nreturned as the value of the entire expression.") + local function match_try_2a(expr, pattern, body, ...) + return case_try_impl(sym('match', nil, {quoted=true, filename="src/fennel/match.fnl", line=388}), expr, pattern, body, ...) + end + utils['fennel-module'].metadata:setall(match_try_2a, "fnl/arglist", {"expr", "pattern", "body", "..."}, "fnl/docstring", "Perform chained pattern matching for a sequence of steps which might fail.\n\nThe values from the initial expression are matched against the first pattern.\nIf they match, the first body is evaluated and its values are matched against\nthe second pattern, etc.\n\nIf there is a (catch pat1 body1 pat2 body2 ...) form at the end, any mismatch\nfrom the steps will be tried against these patterns in sequence as a fallback\njust like a normal match. If there is no catch, the mismatched values will be\nreturned as the value of the entire expression.") + return {["case-try"] = case_try_2a, ["match-try"] = match_try_2a, case = case_2a, match = match_2a} + ]===], env) +end + +local fennel = mod +fennel.install({global = true}) + +function on_search(str) + if not str:starts_with("(") then return end + if not str:ends_with(")") then return end + search:show_lines({fennel.eval(str)}) +end + -- 2.43.0 From 1fefd5791bea5ed6ca8b12bef52e284eca58c33f Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 22 Jul 2025 12:01:46 +0800 Subject: [PATCH 202/204] Add Time & Date widget --- community/time-date-widget.lua | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 community/time-date-widget.lua diff --git a/community/time-date-widget.lua b/community/time-date-widget.lua new file mode 100644 index 0000000..c0be1a4 --- /dev/null +++ b/community/time-date-widget.lua @@ -0,0 +1,41 @@ +-- name = "Time & Date" +-- description = "Simple widget showing current time and date" +-- author = "Evgeny Zobnin (zobnin@gmail.com) +-- type = "widget" +-- aio_version = "5.2.1" + +local function draw() + local now = os.date("*t") + local time = string.format("%02d:%02d", now.hour, now.min) + local date = os.date("%a, %d %b") + + gui{ + {"spacer", 2}, + {"text", time, { size = 40 }}, + {"text", date, { size = 20, gravity = "right|center_v" }}, + {"spacer", 2}, + }.render() +end + +function on_tick() + draw() +end + +function on_click(idx) + -- time + if idx == 2 then + intent:start_activity{ + action = "android.intent.action.SHOW_ALARMS" + } + return + end + + -- date + if idx == 3 then + intent:start_activity{ + action = "android.intent.action.MAIN", + category = "android.intent.category.APP_CALENDAR" + } + end +end + -- 2.43.0 From fefa35c95d669fcbc866d1b43c44fc05e9198caf Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 2 Aug 2025 14:07:17 +0800 Subject: [PATCH 203/204] Small meta data change fix in the Time & Date widget --- community/time-date-widget.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/community/time-date-widget.lua b/community/time-date-widget.lua index c0be1a4..0fa145e 100644 --- a/community/time-date-widget.lua +++ b/community/time-date-widget.lua @@ -1,6 +1,6 @@ -- name = "Time & Date" -- description = "Simple widget showing current time and date" --- author = "Evgeny Zobnin (zobnin@gmail.com) +-- author = "Evgeny Zobnin (zobnin@gmail.com)" -- type = "widget" -- aio_version = "5.2.1" -- 2.43.0 From 6ff2737535358eddd0502f73cd537a8a05128db3 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 2 Sep 2025 16:05:24 +0800 Subject: [PATCH 204/204] Add bible search script --- community/bible-search.lua | 313 +++++++++++++++++++++++++++++++++++++ 1 file changed, 313 insertions(+) create mode 100644 community/bible-search.lua diff --git a/community/bible-search.lua b/community/bible-search.lua new file mode 100644 index 0000000..f31e27c --- /dev/null +++ b/community/bible-search.lua @@ -0,0 +1,313 @@ +-- name = "Bible Search" +-- type = "search" +-- author = "Evon Smith" +-- description = "Type in Bible book and chapter to open the YouVersion Bible App to that location right from the search window" +-- version = "2.0" + +------------------------------------------------------------ +-- Complete Bible books list with aliases and chapters +------------------------------------------------------------ +local BOOKS = { + { name = "Genesis", aliases = {"genesis","gen","ge"}, chapters = 50, osis = "GEN" }, + { name = "Exodus", aliases = {"exodus","exo","ex"}, chapters = 40, osis = "EXO" }, + { name = "Leviticus", aliases = {"leviticus","lev","le"}, chapters = 27, osis = "LEV" }, + { name = "Numbers", aliases = {"numbers","num","nu","nm"}, chapters = 36, osis = "NUM" }, + { name = "Deuteronomy", aliases = {"deuteronomy","deut","dt"}, chapters = 34, osis = "DEU" }, + { name = "Joshua", aliases = {"joshua","josh","jos"}, chapters = 24, osis = "JOS" }, + { name = "Judges", aliases = {"judges","judg","jdg"}, chapters = 21, osis = "JDG" }, + { name = "Ruth", aliases = {"ruth","ru"}, chapters = 4, osis = "RUT" }, + { name = "1 Samuel", aliases = {"1samuel","1sam","1sa","i samuel","1 sam"}, chapters = 31, osis = "1SA" }, + { name = "2 Samuel", aliases = {"2samuel","2sam","2sa","ii samuel","2 sam"}, chapters = 24, osis = "2SA" }, + { name = "1 Kings", aliases = {"1kings","1ki","i kings","1 ki"}, chapters = 22, osis = "1KI" }, + { name = "2 Kings", aliases = {"2kings","2ki","ii kings","2 ki"}, chapters = 25, osis = "2KI" }, + { name = "1 Chronicles", aliases = {"1chronicles","1chr","i chronicles","1 chr"}, chapters = 29, osis = "1CH" }, + { name = "2 Chronicles", aliases = {"2chronicles","2chr","ii chronicles","2 chr"}, chapters = 36, osis = "2CH" }, + { name = "Ezra", aliases = {"ezra","ezr"}, chapters = 10, osis = "EZR" }, + { name = "Nehemiah", aliases = {"nehemiah","neh","ne"}, chapters = 13, osis = "NEH" }, + { name = "Esther", aliases = {"esther","est","es"}, chapters = 10, osis = "EST" }, + { name = "Job", aliases = {"job","jb"}, chapters = 42, osis = "JOB" }, + { name = "Psalms", aliases = {"psalms","psalm","ps","psa"}, chapters = 150, osis = "PSA" }, + { name = "Proverbs", aliases = {"proverbs","prov","prv","pr"}, chapters = 31, osis = "PRO" }, + { name = "Ecclesiastes", aliases = {"ecclesiastes","eccl","ecc"}, chapters = 12, osis = "ECC" }, + { name = "Song of Solomon", aliases = {"songofsolomon","song","so","ss","song of songs","songs"}, chapters = 8, osis = "SNG" }, + { name = "Isaiah", aliases = {"isaiah","isa","is"}, chapters = 66, osis = "ISA" }, + { name = "Jeremiah", aliases = {"jeremiah","jer","je"}, chapters = 52, osis = "JER" }, + { name = "Lamentations", aliases = {"lamentations","lam","la"}, chapters = 5, osis = "LAM" }, + { name = "Ezekiel", aliases = {"ezekiel","ezek","eze"}, chapters = 48, osis = "EZK" }, + { name = "Daniel", aliases = {"daniel","dan","da"}, chapters = 12, osis = "DAN" }, + { name = "Hosea", aliases = {"hosea","hos","ho"}, chapters = 14, osis = "HOS" }, + { name = "Joel", aliases = {"joel","jl"}, chapters = 3, osis = "JOL" }, + { name = "Amos", aliases = {"amos","am"}, chapters = 9, osis = "AMO" }, + { name = "Obadiah", aliases = {"obadiah","obad","ob"}, chapters = 1, osis = "OBA" }, + { name = "Jonah", aliases = {"jonah","jon","jh"}, chapters = 4, osis = "JON" }, + { name = "Micah", aliases = {"micah","mic","mc"}, chapters = 7, osis = "MIC" }, + { name = "Nahum", aliases = {"nahum","nah","na"}, chapters = 3, osis = "NAM" }, + { name = "Habakkuk", aliases = {"habakkuk","hab","hb"}, chapters = 3, osis = "HAB" }, + { name = "Zephaniah", aliases = {"zephaniah","zeph","zep"}, chapters = 3, osis = "ZEP" }, + { name = "Haggai", aliases = {"haggai","hag","hg"}, chapters = 2, osis = "HAG" }, + { name = "Zechariah", aliases = {"zechariah","zech","zec"}, chapters = 14, osis = "ZEC" }, + { name = "Malachi", aliases = {"malachi","mal","ml"}, chapters = 4, osis = "MAL" }, + { name = "Matthew", aliases = {"matthew","matt","mt"}, chapters = 28, osis = "MAT" }, + { name = "Mark", aliases = {"mark","mk","mrk"}, chapters = 16, osis = "MRK" }, + { name = "Luke", aliases = {"luke","lk","luk"}, chapters = 24, osis = "LUK" }, + { name = "John", aliases = {"john","jn","jhn"}, chapters = 21, osis = "JHN" }, + { name = "Acts", aliases = {"acts","ac","acts of the apostles"}, chapters = 28, osis = "ACT" }, + { name = "Romans", aliases = {"romans","rom","ro"}, chapters = 16, osis = "ROM" }, + { name = "1 Corinthians", aliases = {"1corinthians","1cor","1co","i corinthians","1 cor"}, chapters = 16, osis = "1CO" }, + { name = "2 Corinthians", aliases = {"2corinthians","2cor","2co","ii corinthians","2 cor"}, chapters = 13, osis = "2CO" }, + { name = "Galatians", aliases = {"galatians","gal","ga"}, chapters = 6, osis = "GAL" }, + { name = "Ephesians", aliases = {"ephesians","eph","ep"}, chapters = 6, osis = "EPH" }, + { name = "Philippians", aliases = {"philippians","phil","php"}, chapters = 4, osis = "PHP" }, + { name = "Colossians", aliases = {"colossians","col","co"}, chapters = 4, osis = "COL" }, + { name = "1 Thessalonians", aliases = {"1thessalonians","1thess","1th","i thessalonians","1 thess"}, chapters = 5, osis = "1TH" }, + { name = "2 Thessalonians", aliases = {"2thessalonians","2thess","2th","ii thessalonians","2 thess"}, chapters = 3, osis = "2TH" }, + { name = "1 Timothy", aliases = {"1timothy","1tim","1ti","i timothy","1 tim"}, chapters = 6, osis = "1TI" }, + { name = "2 Timothy", aliases = {"2timothy","2tim","2ti","ii timothy","2 tim"}, chapters = 4, osis = "2TI" }, + { name = "Titus", aliases = {"titus","tit","ti"}, chapters = 3, osis = "TIT" }, + { name = "Philemon", aliases = {"philemon","philem","phm"}, chapters = 1, osis = "PHM" }, + { name = "Hebrews", aliases = {"hebrews","heb","he"}, chapters = 13, osis = "HEB" }, + { name = "James", aliases = {"james","jas","jm"}, chapters = 5, osis = "JAS" }, + { name = "1 Peter", aliases = {"1peter","1pet","1pe","i peter","1 pet"}, chapters = 5, osis = "1PE" }, + { name = "2 Peter", aliases = {"2peter","2pet","2pe","ii peter","2 pet"}, chapters = 3, osis = "2PE" }, + { name = "1 John", aliases = {"1john","1jn","i john","1 jn"}, chapters = 5, osis = "1JN" }, + { name = "2 John", aliases = {"2john","2jn","ii john","2 jn"}, chapters = 1, osis = "2JN" }, + { name = "3 John", aliases = {"3john","3jn","iii john","3 jn"}, chapters = 1, osis = "3JN" }, + { name = "Jude", aliases = {"jude","jud"}, chapters = 1, osis = "JUD" }, + { name = "Revelation", aliases = {"revelation","rev","re","revelations"}, chapters = 22, osis = "REV" }, +} + +-- Build alias lookup table +local ALIAS = {} +local function _norm(s) return (s or ""):lower():gsub("[%s%p]+","") end +for _, b in ipairs(BOOKS) do + ALIAS[_norm(b.name)] = b + for _, a in ipairs(b.aliases) do ALIAS[_norm(a)] = b end +end + +------------------------------------------------------------ +-- State management +------------------------------------------------------------ +local suggestions = {} -- Store all clickable suggestions with their URLs +local currentQuery = "" + +------------------------------------------------------------ +-- Helper functions +------------------------------------------------------------ +local function trim(s) return (s or ""):match("^%s*(.-)%s*$") end + +-- Enhanced parser that handles multi-word book names better +local function parse_book_chapter(q) + q = trim(q or "") + if q == "" then return nil, nil end + + -- Try to match book name with optional chapter + -- This pattern allows for multi-word book names + local book_part, chapter_part = q:match("^(.-)%s+(%d+)$") + + if book_part and chapter_part then + -- Found both book and chapter + return trim(book_part), tonumber(chapter_part) + else + -- No chapter number found, treat entire query as book name + return q, nil + end +end + +-- Enhanced book resolver for better multi-word matching +local function resolve_book(letters) + if not letters then return nil end + + local key = _norm(letters) + + -- Exact match first + if ALIAS[key] then return ALIAS[key] end + + -- Try partial matching for better multi-word support + local matches = {} + for ak, b in pairs(ALIAS) do + if ak:find("^" .. key) then + table.insert(matches, {alias = ak, book = b, priority = 1}) + elseif ak:find(key, 1, true) then + table.insert(matches, {alias = ak, book = b, priority = 2}) + end + end + + -- Return best match if found + if #matches > 0 then + table.sort(matches, function(a, b) + if a.priority == b.priority then + return #a.alias < #b.alias -- Prefer shorter matches + end + return a.priority < b.priority + end) + return matches[1].book + end + + return nil +end + +local function build_youversion_url(osis, chapter) + return string.format("youversion://bible?reference=%s.%d", osis, chapter) +end + +-- Get matching books based on query +local function get_matching_books(query) + if not query or query == "" then + return BOOKS -- Return all books if no query + end + + local matches = {} + local key = _norm(query) + + for _, book in ipairs(BOOKS) do + local book_key = _norm(book.name) + local is_match = false + + -- Check if book name starts with query + if book_key:find("^" .. key) then + is_match = true + else + -- Check aliases + for _, alias in ipairs(book.aliases) do + if _norm(alias):find("^" .. key) then + is_match = true + break + end + end + end + + if is_match then + table.insert(matches, book) + end + end + + -- If no matches found with prefix matching, try substring matching + if #matches == 0 then + for _, book in ipairs(BOOKS) do + local book_key = _norm(book.name) + if book_key:find(key, 1, true) then + table.insert(matches, book) + end + end + end + + return #matches > 0 and matches or BOOKS +end + +------------------------------------------------------------ +-- Main search function +------------------------------------------------------------ +function on_search(query) + currentQuery = query + suggestions = {} + + local book_part, chapter = parse_book_chapter(query) + + if book_part then + local specific_book = resolve_book(book_part) + + if specific_book and chapter then + -- Specific book and chapter requested + if chapter >= 1 and chapter <= specific_book.chapters then + local url = build_youversion_url(specific_book.osis, chapter) + suggestions[1] = { + text = string.format("Open %s %d in YouVersion", specific_book.name, chapter), + url = url + } + search:show_buttons({suggestions[1].text}) + return + else + search:show_lines({ + string.format("%s only has %d chapter%s", + specific_book.name, + specific_book.chapters, + specific_book.chapters == 1 and "" or "s") + }) + return + end + end + end + + -- Show book/chapter suggestions + local matching_books = get_matching_books(book_part) + local button_texts = {} + local max_suggestions = 10 -- Limit number of suggestions shown + local suggestion_count = 0 + + for _, book in ipairs(matching_books) do + if suggestion_count >= max_suggestions then break end + + -- If book has few chapters, show all in one line + if book.chapters <= 5 then + local chapters_text = "" + for ch = 1, book.chapters do + if ch > 1 then chapters_text = chapters_text .. ", " end + chapters_text = chapters_text .. ch + end + suggestion_count = suggestion_count + 1 + local idx = #suggestions + 1 + suggestions[idx] = { + text = string.format("%s (Ch: %s)", book.name, chapters_text), + book = book, + all_chapters = true + } + table.insert(button_texts, suggestions[idx].text) + else + -- For books with many chapters, show range + suggestion_count = suggestion_count + 1 + local idx = #suggestions + 1 + suggestions[idx] = { + text = string.format("%s (1-%d chapters)", book.name, book.chapters), + book = book, + all_chapters = true + } + table.insert(button_texts, suggestions[idx].text) + end + end + + if #button_texts == 0 then + search:show_lines({"No matching books found. Try: Genesis, John, Psalms..."}) + else + search:show_buttons(button_texts) + end +end + +------------------------------------------------------------ +-- Handle button clicks +------------------------------------------------------------ +function on_click(index) + if not index then index = 1 end + + local suggestion = suggestions[index] + if not suggestion then return false end + + -- If it's a direct chapter link, open it + if suggestion.url then + system:open_browser(suggestion.url) + return true + end + + -- If it's a book suggestion, show its chapters + if suggestion.book and suggestion.all_chapters then + local book = suggestion.book + suggestions = {} + local button_texts = {} + + -- Create buttons for each chapter + for ch = 1, book.chapters do + local idx = #suggestions + 1 + local url = build_youversion_url(book.osis, ch) + suggestions[idx] = { + text = string.format("%s %d", book.name, ch), + url = url + } + table.insert(button_texts, suggestions[idx].text) + end + + search:show_buttons(button_texts) + return false -- Don't close search, allow chapter selection + end + + return false +end + -- 2.43.0