diff options
-rw-r--r-- | dalos-input.lua | 41 | ||||
-rw-r--r-- | dalos.lua | 1 |
2 files changed, 42 insertions, 0 deletions
diff --git a/dalos-input.lua b/dalos-input.lua new file mode 100644 index 0000000..1061619 --- /dev/null +++ b/dalos-input.lua @@ -0,0 +1,41 @@ +dalosp.input = {
+ get_settings = function (self)
+ return { filename = extra.filename }
+ end,
+
+ configure = function (self)
+ local dlg = iup.filedlg {
+ dialogtype = "Open",
+ file = self.extra.filename,
+ }
+ iup.Popup(dlg)
+ if dlg.status ~= -1 then
+ local s, v = pcall(Input, dlg.value)
+ if s then
+ obj:set_houtput(v)
+ return
+ end
+ end
+ obj:set_houtput(nil)
+ end,
+
+ create = function (d, tab, settings)
+ tab.ninputs = 0
+ tab.noutputs = 1
+ tab.otype = dalos.objtype.HANDLE
+ tab.configure = dalosp.input.configure
+ tab.default_name = "Input"
+ tab.get_settings = dalosp.input.get_settings
+ local extra = { }
+ if settings then extra.filename = settings.filename end
+ local obj = dalos.object(d, tab, extra)
+
+ if extra.filename then
+ local s, v = pcall(Input, extra.filename)
+ if s then obj:set_houtput(v) end
+ end
+ end,
+}
+
+dalos.input = dalosp.input.create
+dalos:register_obj("Input", dalos.input)
@@ -680,6 +680,7 @@ load "dalos-hexview.lua" load "dalos-binaryops.lua" load "dalos-limiter.lua" load "dalos-textbuffer.lua" +load "dalos-input.lua" ---------------- |