diff options
-rw-r--r-- | dalos-binaryops.lua | 2 | ||||
-rw-r--r-- | dalos-hexview.lua | 16 | ||||
-rw-r--r-- | dalos-input.lua | 4 | ||||
-rw-r--r-- | dalos-limiter.lua | 2 | ||||
-rw-r--r-- | dalos-textbuffer.lua | 2 | ||||
-rw-r--r-- | dalos.lua | 73 |
6 files changed, 77 insertions, 22 deletions
diff --git a/dalos-binaryops.lua b/dalos-binaryops.lua index 17c9b63..022020c 100644 --- a/dalos-binaryops.lua +++ b/dalos-binaryops.lua @@ -105,6 +105,8 @@ Maximize: %b[No,Yes]{Check if you want to maximize the output} if settings then extra.op = settings.op extra.maximize = settings.maximize end
local obj = dalos.object(d, tab, extra)
+
+ return obj
end,
}
diff --git a/dalos-hexview.lua b/dalos-hexview.lua index 26eaa77..a302d39 100644 --- a/dalos-hexview.lua +++ b/dalos-hexview.lua @@ -45,7 +45,7 @@ dalosp.hexview = { nblines = hv.nblines + 0,
}
for i = 1, 10 do
- rmarkers[i] = hv.markers[i] + 0
+ r.markers[i] = hv.markers[i] + 0
end
return r
end,
@@ -109,7 +109,7 @@ dalosp.hexview = { tab.input_change = dalosp.hexview.input_change
tab.output_change = dalosp.hexview.output_change
tab.configure = dalosp.hexview.configure
- tab.get_settings = dalosp.get_settings
+ tab.get_settings = dalosp.hexview.get_settings
tab.ninputs = 1
tab.noutputs = 12
tab.default_name = "Hexview"
@@ -135,14 +135,14 @@ dalosp.hexview = { if settings then
if settings.markers then
for i = 1, 10 do
- hv.markers[i] = settings.markers[i]
+ if settings.markers[i] then hv.markers[i] = settings.markers[i] end
end
end
- hv.mcursor = settings.mcursor
- hv.kcursor = settings.kcursor
- hv.filecursor = settings.filecursor
- hv.nbbytes = settings.nbbytes
- hv.nblines = settings.nblines
+ if settings.mcursor then hv.mcursor = settings.mcursor end
+ if settings.kcursor then hv.kcursor = settings.kcursor end
+ if settings.filecursor then hv.filecursor = settings.filecursor end
+ if settings.nbbytes then hv.nbbytes = settings.nbbytes end
+ if settings.nblines then hv.nblines = settings.nblines end
end
hv:registercb(dalosp.hexview.dalos_hv_cb, obj)
diff --git a/dalos-input.lua b/dalos-input.lua index 86dce5a..be2cf75 100644 --- a/dalos-input.lua +++ b/dalos-input.lua @@ -34,7 +34,9 @@ dalosp.input = { if extra.filename then
local s, v = pcall(Input, extra.filename)
if s then obj:set_houtput(v) end
- end
+ end
+
+ return obj
end,
}
diff --git a/dalos-limiter.lua b/dalos-limiter.lua index d27c0b5..ee9b106 100644 --- a/dalos-limiter.lua +++ b/dalos-limiter.lua @@ -50,6 +50,8 @@ Limit: %i{The actual size this limiter is going to produce} if settings then extra.limit = settings.limit end
local obj = dalos.object(d, tab, extra)
+
+ return obj
end,
}
diff --git a/dalos-textbuffer.lua b/dalos-textbuffer.lua index d52bb76..cd91689 100644 --- a/dalos-textbuffer.lua +++ b/dalos-textbuffer.lua @@ -26,6 +26,8 @@ dalosp.textbuffer = { if settings then extra.text = settings.text end
local obj = dalos.object(d, tab, extra)
+
+ return obj
end,
}
@@ -18,7 +18,7 @@ dalosp.cross = { } function dalos:register_obj(name, constructor) if self.objectstypes_by_name[name] then - error("An object of that name already exists: " .. name) + error("An object type of that name already exists: " .. name) end table.insert(self.objectstypes, { name = name, constructor = constructor, counter = 1 }) self.objectstypes_by_name[name] = #self.objectstypes @@ -27,6 +27,18 @@ function dalos:register_obj(name, constructor) end end +function dalos:clean() + local d = dalos.active_canvas + for k, v in ipairs(d.objects) do + for ind = 1, v.obj.noutputs do + d:destroylink(v, ind) + end + end + + while #d.objects ~= 0 do table.remove(d.objects) end + d.objects = {} +end + dalosp.canvas = { DARK_WHITE = cd.EncodeColor(224, 224, 224), BEZIER_CTRL_LEN = 40, @@ -243,9 +255,11 @@ dalosp.canvas = { end end, - createlink = function (self, src, dst) - local oldsrc = src.obj.outputs[src.obj.curoutput] - local olddst = dst.obj.inputs[dst.obj.curinput] + createlink = function (self, src, dst, srcind, dstind) + if not srcind then srcind = src.obj.curoutput end + if not dstind then dstind = dst.obj.curinput end + local oldsrc = src.obj.outputs[srcind] + local olddst = dst.obj.inputs[dstind] if oldsrc then oldsrc.obj.obj.inputs[oldsrc.ind] = nil oldsrc.obj.obj:input_change(oldsrc.ind) @@ -254,17 +268,18 @@ dalosp.canvas = { olddst.obj.obj.outputs[olddst.ind] = nil olddst.obj.obj:output_change(olddst.ind) end - src.obj.outputs[src.obj.curoutput] = { obj = dst, ind = dst.obj.curinput } - dst.obj.inputs[dst.obj.curinput] = { obj = src, ind = src.obj.curoutput } - src.obj:output_change(src.obj.curoutput) - dst.obj:input_change(dst.obj.curinput) + src.obj.outputs[src.obj.curoutput] = { obj = dst, ind = dstind } + dst.obj.inputs[dst.obj.curinput] = { obj = src, ind = srcind } + src.obj:output_change(srcind) + dst.obj:input_change(dstind) end, - destroylink = function (self, src) - local oldsrc = src.obj.outputs[src.obj.curoutput] + destroylink = function (self, src, ind) + if not ind then ind = src.obj.curoutput end + local oldsrc = src.obj.outputs[ind] if oldsrc then - src.obj.outputs[src.obj.curoutput] = nil - src.obj:output_change(src.obj.curoutput) + src.obj.outputs[ind] = nil + src.obj:output_change(ind) oldsrc.obj.obj.inputs[oldsrc.ind] = nil oldsrc.obj.obj:input_change(oldsrc.ind) @@ -424,6 +439,39 @@ dalosp.canvas = { dalosp.menu = { action_load = function (self) + local dlg = iup.filedlg { + dialogtype = "Open", + } + iup.Popup(dlg) + if dlg.status == -1 then return end + + local s, v = pcall(Input, dlg.value) + if not s then error("Problem loading file " .. dlg.value) end + local f = preload(v) + if not f then error("Syntax error loading file " .. dlg.value) end + local data = f() + local tlup = dalos.objectstypes_by_name + local ot = dalos.objectstypes + local d = dalos.active_canvas + local lup = {} + for k, v in ipairs(data.objects) do + if not tlup[v.ntype] then error("Object " .. v.ntype .. " isn't declared") end + end + dalos:clean() + for k, v in ipairs(data.objects) do + local tab = { x = v.x, y = v.y, name = v.name } + local o = ot[tlup[v.ntype]].constructor(d, tab, v.settings) + for iobj, obj in ipairs(d.objects) do + if obj.obj == o then + lup[iobj] = obj + end + end + end + for k, v in ipairs(data.links) do + if not lup[v.src] then error("Can't find object for id src " .. v.src) end + if not lup[v.dst] then error("Can't find object for id dst " .. v.dst) end + d:createlink(lup[v.src], lup[v.dst], v.isrc, v.idst) + end end, action_save = function(self) @@ -452,7 +500,6 @@ dalosp.menu = { } iup.Popup(dlg) if dlg.status ~= -1 then - print(dlg.value) local s, v = pcall(Output, dlg.value) if s then v:write "local " |