-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple-strip-wrapper.lua
More file actions
48 lines (39 loc) · 1.21 KB
/
simple-strip-wrapper.lua
File metadata and controls
48 lines (39 loc) · 1.21 KB
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
function OnClear()
scite.StripShow("")
end
function StripDlg(args)
local t = {}
for k, v in string.gmatch(args, "(%w+)=([^ ]+)") do t[k] = v end
if t["func"] then
StripFunc = t["func"]
if not t["dlg"] then t["dlg"] = "'" .. t["func"] .. "'[](&OK)(&Cancel)" end
_, w = t["dlg"]:gsub("['{}%(%)%[%]]", "")
scite.StripShow(t["dlg"]:gsub('\\n', '\n'))
else
print("Invalid call")
end
end
function OnStrip(control, change)
if change == 1 then
local val = {}
for i = 0, w/2-1 do
if scite.StripValue(i) ~= "" then table.insert(val, scite.StripValue(i)) end
end
StripExec(val[1], val[2], control)
end
end
function StripExec(val1, val2, c)
if editor:GetSelText() == "" then editor:SelectAll() end
if StripFunc == "Lookfor" then
local val = val1
if val2 then val = val .. "', '" .. val2 end
if c == 5 then
val = 'pydoc numpy.lookfor'
else
val = 'python -c "from numpy import lookfor; lookfor(\'' .. val .. '\')"'
end
local o = io.popen(val)
print(o:read("*a"))
o:close()
end
end