aboutsummaryrefslogtreecommitdiff
path: root/core/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'core/init.lua')
-rw-r--r--core/init.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/core/init.lua b/core/init.lua
index f699b8e0..d2eff849 100644
--- a/core/init.lua
+++ b/core/init.lua
@@ -14,6 +14,26 @@ function textadept.check_focused_buffer(buffer)
end
end
+---
+-- Displays a CocoaDialog of a specified type with given arguments returning
+-- the result.
+-- @param kind The CocoaDialog type.
+-- @param ... A table of key, value arguments. Each key is a --key switch with
+-- a "value" value. If value is nil, it is omitted and just the switch is
+-- used.
+-- @return string CocoaDialog result.
+function cocoa_dialog(kind, opts)
+ local args = ''
+ for k, v in pairs(opts) do
+ args = args..' --'..k
+ if type(v) == 'string' then args = args..' "'..v..'"' end
+ end
+ local p = io.popen('CocoaDialog '..kind..args)
+ local out = p:read('*all')
+ p:close()
+ return out
+end
+
package.path = package.path..';'.._HOME..'/core/?.lua'
require 'iface'