summaryrefslogtreecommitdiff
path: root/dalos.lua
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2009-12-22 08:41:00 +0100
committerPixel <pixel@nobis-crew.org>2009-12-22 08:41:00 +0100
commit1a74fe712bb4d1c3f968e943b2f8de89420a6a3f (patch)
treedb65b18118695e61fb822504f3eba168472ca3cb /dalos.lua
parentf65c63f2db769bbc39e7941b3e1572b69e544971 (diff)
Adding luafilter!
Diffstat (limited to 'dalos.lua')
-rw-r--r--dalos.lua62
1 files changed, 60 insertions, 2 deletions
diff --git a/dalos.lua b/dalos.lua
index 4b2eb80..d8169e5 100644
--- a/dalos.lua
+++ b/dalos.lua
@@ -2,6 +2,22 @@ loadmodule "luaiup"
loadmodule "luahandle"
loadmodule "lualibs"
+--[[
+load "indent.lua"
+
+function testIndenter(i)
+ local lib = IndentationLib
+ local str = ""
+ local inp = Input "dalos.lua"
+ str = inp:readfile()
+
+ local colorTable = lib.defaultColorTable
+ print(lib.indentCode(str, 4, colorTable, i))
+end
+
+testIndenter()
+]]--
+
load "iupe-dbuffer.lua"
load "iupe-tview.lua"
@@ -167,6 +183,18 @@ dalosp.canvas = {
self:draw()
end,
+ delobj = function (self, ind)
+ local obj = self.objects[ind]
+ for i = 1, obj.obj.noutputs do
+ self:destroylink(obj, i)
+ end
+ for i = 1, obj.obj.ninputs do
+ self:destroylink_dst(obj, i)
+ end
+ table.remove(self.objects, ind)
+ self:draw()
+ end,
+
findobj = function (self, x, y)
local obj, ind
@@ -213,6 +241,7 @@ dalosp.canvas = {
end,
motion_cb = function (self, x, y, status)
+ self.stateful.mousepos = { x = x, y = y }
if self.stateful.panning then
local ox, oy = self.ox, self.oy
local dx, dy = x - ox, y - oy
@@ -288,6 +317,18 @@ dalosp.canvas = {
end
end,
+ destroylink_dst = function (self, dst, ind)
+ if not ind then ind = dst.obj.curinput end
+ local olddst = dst.obj.inputs[ind]
+ if olddst then
+ dst.obj.inputs[ind] = nil
+ dst.obj:input_change(ind)
+
+ olddst.obj.obj.outputs[olddst.ind] = nil
+ olddst.obj.obj:output_change(olddst.ind)
+ end
+ end,
+
button_cb = function (self, button, pressed, x, y, status)
if not pressed then pressed = 0 end
if not x then x = self.ox end
@@ -374,7 +415,7 @@ dalosp.canvas = {
self.menu.y = nil
self:draw()
elseif self.stateful.moving then
- -- check for the trash can
+ -- dropped somewhere... do something useful here ?
end
self.stateful.panning = nil
self.stateful.moving = nil
@@ -403,6 +444,19 @@ dalosp.canvas = {
self:draw()
end,
+ keypress_cb = function (self, c, press)
+ if press ~= 1 then return end
+ local obj, ind = self:findobj(self.stateful.mousepos.x, self.stateful.mousepos.y)
+ if c == iup.K_cS then
+ if obj then self:delobj(ind) end
+ elseif c == iup.K_n then
+ if not obj then return end
+ local s, newname = iup.GetParam("Renaming", nil, "Set name: %s\n", obj.obj.name)
+ if s and newname then obj.obj.name = newname end
+ self:draw()
+ end
+ end,
+
create = function (tab)
tab.border = "No"
tab.expand = "Yes"
@@ -419,7 +473,9 @@ dalosp.canvas = {
r.motion_cb = dalosp.canvas.motion_cb
r.button_cb = dalosp.canvas.button_cb
r.wheel_cb = dalosp.canvas.wheel_cb
+ r.keypress_cb = dalosp.canvas.keypress_cb
r.addobj = dalosp.canvas.addobj
+ r.delobj = dalosp.canvas.delobj
r.findobj = dalosp.canvas.findobj
r.moveobj = dalosp.canvas.moveobj
r.setobjplace = dalosp.canvas.setobjplace
@@ -427,6 +483,7 @@ dalosp.canvas = {
r.setstatus = dalosp.canvas.setstatus
r.createlink = dalosp.canvas.createlink
r.destroylink = dalosp.canvas.destroylink
+ r.destroylink_dst = dalosp.canvas.destroylink_dst
r.drawlink = dalosp.canvas.drawlink
r.drawxmenu = dalosp.canvas.drawxmenu
r.origin = { x = 0, y = 0 }
@@ -817,6 +874,7 @@ load "dalos-textbuffer.lua"
load "dalos-input.lua"
load "dalos-tee.lua"
load "dalos-buffer.lua"
+load "dalos-luafilter.lua"
----------------
@@ -833,4 +891,4 @@ function dalos:main()
dlg:hide()
end
-dalos:main()
+if not archive_main then dalos:main() end