-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.lua
108 lines (92 loc) · 1.92 KB
/
events.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
-- aBsh button triggered function
-- require utils for helper function
require "utils"
require "import"
import "android.widget.*"
import "android.view.*"
-- return var ident
RET="ret"
-- none message
NONE="(none)"
-- btn_lua
function doLuaEval()
local text=getScript()
luaDoString(lua, text)
local o=luaGetObject(lua, RET)
result=tostring(o)
result_class=type(o)
end
-- btn_lua longclick
function doLuaEvalWithFn()
local text=getScript()
local o=luaScript(lua, text, "")
result=tostring(o)
result_class=type(o)
end
-- btn_java
function doBshEval()
local text=getScript()
local o=bshEval(bsh, text)
result_class=type(o)
result=luajava.tostring(o)
end
-- btn_result
function showResult()
AlertDialog.Builder(activity)
.setTitle(result_class or NONE)
.setMessage(result or NONE)
.show()
end
-- btn_exit
function exit()
activity.finish()
end
-- btn_get
function get_obj()
local text=getScript()
o=bshGetObj(bsh, text)
result_class=type(o)
result=luajava.tostring(o)
end
-- btn_set
function set_obj()
local text=getScript()
local t=EditText(activity)
t.setHint("٩(๑ᵒ̴̶̷͈᷄ᗨᵒ̴̶̷͈᷅)و 长按保存变量名")
local a=AlertDialog.Builder(activity)
.setView(t)
.show()
t.onLongClick=function()
bshSetObj(bsh, t.Text, text)
a.dismiss()
end
end
-- btn_strict
function strict()
print(not toggleStrict(bsh))
end
-- btn_source
function source()
local text=getScript()
luaSource(lua, "/data/data/org.duangsuse.alua.beanshell/files/lua"..text..".lua")
o=bshSource(bsh, text)
result=luajava.tostring(o)
result_class=type(o)
end
-- btn_mod
function mod()
local text=getScript()
if text=="CTX" then bshSetObj(bsh, CTX, activity.getContext()) else
bshLoadLib(text)
end
end
function putsBshVersion()
print(bshVersion(bsh))
end
function togdebug()
print(not toggleDebug(bsh))
end
function redirout()
local text=getScript()
bshredir(bsh, text)
end