_Nullable item, NSError * _Null_unspecified error) {
50 |
51 | NSURL * _Nullable url = (NSURL *)item;
52 |
53 | if ([url isKindOfClass: NSURL.class]) {
54 | lua_pushstring(L, [[url absoluteString] UTF8String]);
55 | } else {
56 | lua_pushnil(L);
57 | }
58 |
59 | dispatch_semaphore_signal(semaphore);
60 | }];
61 |
62 | if (lua_extensionContext) {
63 | dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
64 | } else {
65 | lua_pushnil(L);
66 | }
67 |
68 | return 1;
69 | }
70 |
71 | static int sharesheet_filePath(lua_State *L) {
72 |
73 | dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
74 |
75 | NSExtensionItem *item = lua_extensionContext.inputItems[0];
76 | NSItemProvider *attachment = item.attachments[0];
77 |
78 | [attachment loadInPlaceFileRepresentationForTypeIdentifier:@"public.content" completionHandler:^(NSURL * _Nullable url, BOOL isInPlace, NSError * _Nullable error) {
79 |
80 | NSString *path = url.path;
81 |
82 | [url startAccessingSecurityScopedResource];
83 | lua_pushstring(L, path.UTF8String);
84 |
85 | dispatch_semaphore_signal(semaphore);
86 | }];
87 |
88 | if (lua_extensionContext) {
89 | dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
90 | } else {
91 | lua_pushnil(L);
92 | }
93 |
94 | return 1;
95 | }
96 |
97 | static int sharesheet_shareItems(lua_State *L) {
98 |
99 | //#if MAINAPP
100 | NSMutableArray *items = [[NSMutableArray alloc] init];
101 |
102 | int argc = lua_gettop(L);
103 | for (int i = 1; i <= argc; i++) {
104 | NSString *str = [NSString stringWithUTF8String: lua_tostring(L, i)];
105 |
106 | NSURL *url;
107 |
108 | if ([[NSFileManager defaultManager] fileExistsAtPath:str isDirectory: nil]) {
109 | url = [NSURL fileURLWithPath: str];
110 | } else {
111 | url = [NSURL URLWithString:str];
112 | }
113 |
114 | if (url && url.scheme != nil && ![url.scheme isEqual: @""]) {
115 | [items addObject: url];
116 | } else {
117 | [items addObject: str];
118 | }
119 | }
120 |
121 | dispatch_async(dispatch_get_main_queue(), ^{
122 | UIActivityViewController *vc = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
123 |
124 | if (lua_viewController) {
125 | vc.popoverPresentationController.sourceRect = lua_viewController.view.bounds;
126 | vc.popoverPresentationController.sourceView = lua_viewController.view;
127 |
128 | [lua_viewController presentViewController:vc animated:YES completion:nil];
129 | }
130 | });
131 |
132 | return 0;
133 | /*#else
134 | return luaL_error(L, "'shareItems' should be only called from the app.");
135 | #endif*/
136 | }
137 |
138 | static const struct luaL_Reg sharesheet_functions[] = {
139 |
140 | { "string", sharesheet_string },
141 | { "url", sharesheet_url },
142 | { "filePath", sharesheet_filePath },
143 | { "shareItems", sharesheet_shareItems },
144 | { NULL, NULL }
145 | };
146 |
147 | int luaopen_sharesheet(lua_State *L) {
148 | /* Create the metatable and put it on the stack. */
149 | luaL_newmetatable(L, "sharesheet");
150 | /* Duplicate the metatable on the stack (We know have 2). */
151 | lua_pushvalue(L, -1);
152 | /* Pop the first metatable off the stack and assign it to __index
153 | * of the second one. We set the metatable for the table to itself.
154 | * This is equivalent to the following in lua:
155 | * metatable = {}
156 | * metatable.__index = metatable
157 | */
158 | lua_setfield(L, -2, "__index");
159 |
160 | /* Register the object.func functions into the table that is at the top of the
161 | * stack. */
162 | luaL_newlib(L, sharesheet_functions);
163 | lua_setglobal(L, "sharesheet");
164 |
165 | return 0;
166 | }
167 |
--------------------------------------------------------------------------------
/Podfile:
--------------------------------------------------------------------------------
1 | # Uncomment the next line to define a global platform for your project
2 | # platform :ios, '9.0'
3 |
4 | target 'Luade' do
5 | # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
6 | use_frameworks!
7 |
8 | # Pods for Luade
9 |
10 | pod 'SourceEditor', :git => 'https://github.com/ronaldmannak/source-editor.git'
11 | pod 'FloatingPanel'
12 | pod 'InputAssistant'
13 | end
14 |
15 | target 'Run Lua Script' do
16 | # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
17 | use_frameworks!
18 |
19 | # Pods for Run Lua Script
20 |
21 | pod 'SourceEditor', :git => 'https://github.com/ronaldmannak/source-editor.git'
22 | pod 'FloatingPanel'
23 | pod 'InputAssistant'
24 | end
25 |
26 | # post install
27 | post_install do |installer|
28 | # Build settings
29 | installer.pods_project.targets.each do |target|
30 | target.build_configurations.each do |config|
31 | config.build_settings = config.build_settings.dup
32 | if config.build_settings['PRODUCT_MODULE_NAME'] == 'SavannaKit' || config.build_settings['PRODUCT_MODULE_NAME'] == 'SourceEditor'
33 | puts "Set Swift version"
34 | config.build_settings['SWIFT_VERSION'] = '4.0'
35 | end
36 | end
37 | end
38 | end
39 |
--------------------------------------------------------------------------------
/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - FloatingPanel (1.2.0)
3 | - InputAssistant (1.0.2)
4 | - SavannaKit (0.9.0)
5 | - SourceEditor (1.0.1):
6 | - SavannaKit (~> 0.9)
7 |
8 | DEPENDENCIES:
9 | - FloatingPanel
10 | - InputAssistant
11 | - SourceEditor (from `https://github.com/ronaldmannak/source-editor.git`)
12 |
13 | SPEC REPOS:
14 | https://github.com/cocoapods/specs.git:
15 | - FloatingPanel
16 | - InputAssistant
17 | - SavannaKit
18 |
19 | EXTERNAL SOURCES:
20 | SourceEditor:
21 | :git: https://github.com/ronaldmannak/source-editor.git
22 |
23 | CHECKOUT OPTIONS:
24 | SourceEditor:
25 | :commit: 49c0a432c156ab7867d52e209971db4df3806b02
26 | :git: https://github.com/ronaldmannak/source-editor.git
27 |
28 | SPEC CHECKSUMS:
29 | FloatingPanel: b6c56634780f25a4b5146025714f3ad5eeb5afb9
30 | InputAssistant: b0b70cd0d69ef7013ecb2a1fa350b7a2786e2e01
31 | SavannaKit: 920c240bde011900df8156200a960dad3ee5edfd
32 | SourceEditor: 4d590385d642c812d08a91941a4bfc90eccf20af
33 |
34 | PODFILE CHECKSUM: ecfbdea7ab0ccf9c5e9569c9dc0d6ad7de994775
35 |
36 | COCOAPODS: 1.5.3
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | Pisth •
3 | Edidown •
4 | Pyto •
5 | Luade
6 |
7 |
8 | 
9 |
10 | 
11 |
12 | # Luade
13 |
14 | ```
15 | Luade is a Lua IDE for iPhone and iPad. You can run code directly on your device and offline.
16 |
17 | Features:
18 |
19 | - Lua with all default libraries like "io"
20 | - Full REPL
21 | - Preinstalled modules to access device information and clipboard
22 | - Run scripts from the share sheet
23 | - Store scripts in iCloud Drive
24 | ```
25 |
26 | ## Building
27 |
28 | `$ ./setup.sh` and then open Luade.xcworkspace.
29 |
--------------------------------------------------------------------------------
/Run Lua Script/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleDisplayName
8 | Run Lua Script
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | XPC!
19 | CFBundleShortVersionString
20 | 3.0.2
21 | CFBundleVersion
22 | 2
23 | NSExtension
24 |
25 | NSExtensionAttributes
26 |
27 | NSExtensionActivationRule
28 |
29 | NSExtensionActivationSupportsFileWithMaxCount
30 | 1
31 | NSExtensionActivationSupportsText
32 |
33 | NSExtensionActivationSupportsWebURLWithMaxCount
34 | 1
35 |
36 |
37 | NSExtensionMainStoryboard
38 | MainInterface
39 | NSExtensionPointIdentifier
40 | com.apple.share-services
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Run Lua Script/Run Lua Script.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.developer.icloud-container-identifiers
6 |
7 | iCloud.$(CFBundleIdentifier)
8 |
9 | com.apple.developer.icloud-services
10 |
11 | CloudDocuments
12 |
13 | com.apple.developer.ubiquity-container-identifiers
14 |
15 | iCloud.$(CFBundleIdentifier)
16 |
17 | com.apple.security.application-groups
18 |
19 | group.luade.sharing
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/docs/Device.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | device
8 |
9 | This module wraps UIDevice
and gives you access to the device information.
10 |
11 | name
12 |
13 | device.name()
14 |
15 | Returns the device's name.
16 |
17 | systemName
18 |
19 | device.systemName()
20 |
21 | Returns the device's system name.
22 |
23 | systemVersion
24 |
25 | device.systemVersion()
26 |
27 | Returns the device's system version.
28 |
29 | model
30 |
31 | device.model()
32 |
33 | Returns the device's model.
34 |
35 | localizedModel
36 |
37 | device.localizedModel()
38 |
39 | Returns the device's localized model.
40 |
41 | isPortrait
42 |
43 | device.isPortrait()
44 |
45 | Returns true
if the device orientation is portrait.
46 |
47 | isLandscape
48 |
49 | device.isLandscape()
50 |
51 | Returns true
if the device orientation is landscape.
52 |
53 | batteryLevel
54 |
55 | device.batteryLevel()
56 |
57 | Returns the battery level of the device.
58 |
59 | isCharging
60 |
61 | device.isCharging()
62 |
63 | Returns true
if the device is charging.
64 |
65 |
--------------------------------------------------------------------------------
/docs/Licenses.md:
--------------------------------------------------------------------------------
1 | # Acknowledgments
2 |
3 | ## FloatingPanel
4 |
5 | ```
6 | MIT License
7 |
8 | Copyright (c) 2018 Shin Yamamoto
9 |
10 | Permission is hereby granted, free of charge, to any person obtaining a copy
11 | of this software and associated documentation files (the "Software"), to deal
12 | in the Software without restriction, including without limitation the rights
13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the Software is
15 | furnished to do so, subject to the following conditions:
16 |
17 | The above copyright notice and this permission notice shall be included in all
18 | copies or substantial portions of the Software.
19 |
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | SOFTWARE.
27 | ```
28 |
29 | ## InputAssistant
30 |
31 | ```
32 | MIT License
33 |
34 | Copyright (c) 2017 Ian McDowell
35 |
36 | Permission is hereby granted, free of charge, to any person obtaining a copy
37 | of this software and associated documentation files (the "Software"), to deal
38 | in the Software without restriction, including without limitation the rights
39 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
40 | copies of the Software, and to permit persons to whom the Software is
41 | furnished to do so, subject to the following conditions:
42 |
43 | The above copyright notice and this permission notice shall be included in all
44 | copies or substantial portions of the Software.
45 |
46 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
47 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
49 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
50 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
51 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
52 | SOFTWARE.
53 | ```
54 |
55 | ## Lua
56 |
57 | ```
58 | Copyright © 1994–2018 Lua.org, PUC-Rio.
59 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
60 |
61 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
62 |
63 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
64 | ```
65 |
66 | ## SavannaKit
67 |
68 | ```
69 | MIT License
70 |
71 | Copyright (c) 2018 Louis D'hauwe
72 |
73 | Permission is hereby granted, free of charge, to any person obtaining a copy
74 | of this software and associated documentation files (the "Software"), to deal
75 | in the Software without restriction, including without limitation the rights
76 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
77 | copies of the Software, and to permit persons to whom the Software is
78 | furnished to do so, subject to the following conditions:
79 |
80 | The above copyright notice and this permission notice shall be included in all
81 | copies or substantial portions of the Software.
82 |
83 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
84 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
85 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
86 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
87 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
88 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
89 | SOFTWARE.
90 | ```
91 |
92 | ## SourceEditor
93 |
94 | ```
95 | MIT License
96 |
97 | Copyright (c) 2018 Louis D'hauwe
98 |
99 | Permission is hereby granted, free of charge, to any person obtaining a copy
100 | of this software and associated documentation files (the "Software"), to deal
101 | in the Software without restriction, including without limitation the rights
102 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
103 | copies of the Software, and to permit persons to whom the Software is
104 | furnished to do so, subject to the following conditions:
105 |
106 | The above copyright notice and this permission notice shall be included in all
107 | copies or substantial portions of the Software.
108 |
109 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
110 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
111 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
112 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
113 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
114 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
115 | SOFTWARE.
116 | ```
117 |
118 | Generated by CocoaPods - https://cocoapods.org
119 |
--------------------------------------------------------------------------------
/docs/Pasteboard.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | pasteboard
8 |
9 | This module is used for copy and pasting data.
10 |
11 | Retrieving text
12 |
13 | string
14 |
15 | pasteboard.string()
16 |
17 | Returns the copied text.
18 |
19 | strings
20 |
21 | pasteboard.strings()
22 |
23 | Returns the copied texts.
24 |
25 | Setting text
26 |
27 | setString
28 |
29 | pasteboard.setString(string)
30 |
31 | Copies the given string.
32 |
33 | setStrings
34 |
35 | pasteboard.setStrings(strings...)
36 |
37 | Copies the given strings.
38 |
39 | Each parameter passed will be copied. Example:
40 |
41 | pasteboard.setStrings("Hello World!", "Bye!")
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/docs/ShareSheet.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | sharesheet
8 |
9 | This module is used for acessing data trough the iOS share sheet and for sharing items. Place a script in the 'Share Sheet' folder to show it on the share sheet. With your scripts, you can share text, URLs and files.
10 |
11 | Retrieving passed data
12 |
13 | string
14 |
15 | sharesheet.string()
16 |
17 | Returns a string passed to the script.
18 |
19 | url
20 |
21 | sharesheet.url()
22 |
23 | Returns an URL passed to the script. (As a String)
24 |
25 | filePath
26 |
27 | sharesheet.filePath()
28 |
29 | Returns the path of a file passed to the script.
30 |
31 | Sharing data
32 |
33 | shareItems
34 |
35 | sharesheet.shareItems(items...)
36 |
37 | Opens the share sheet for sharing the given items.
38 | Each parameter passed will be a shared items. Example:
39 |
40 | sharesheet.shareItems("Hello World!", "https://develobile.com")
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Documentation
8 |
9 | Luade has some modules made just for the app.
10 |
11 | You can import another script that is on the same directory than the script you are editing with require "scriptName"
.
12 |
13 | Libraries
14 |
21 |
22 | Functions
23 |
24 | openURL(string)
25 | Opens the given URL.
26 |
27 | Returns: true
if the URL was opened successfully.
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/docs/styles.css:
--------------------------------------------------------------------------------
1 |
2 | body {
3 | color: white;
4 | font-family: Helvetica;
5 | background-color: #212121;
6 | }
7 |
8 | a {
9 | color: rgb(0, 122, 255);
10 | text-decoration: none;
11 | }
12 |
--------------------------------------------------------------------------------
/mockup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ColdGrub1384/Luade/cab270248a6b744d745fbb157b9f8c441d977993/mockup.png
--------------------------------------------------------------------------------
/setup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
4 | cd "$DIR"
5 |
6 | pod install
7 |
8 | git submodule init
9 | git submodule update
10 |
--------------------------------------------------------------------------------