From f773c7414b9968e9980261a3fa603ca29462b841 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Dec 2009 23:33:55 -0800 Subject: Dalos.hexview code almost complete. --- dalos.lua | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/dalos.lua b/dalos.lua index 8172c99..aecb561 100644 --- a/dalos.lua +++ b/dalos.lua @@ -152,9 +152,11 @@ dalosp.canvas = { end if olddst then 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) end, @@ -371,9 +373,16 @@ dalosp.object = { default_inputchange = function (self, ind) end, + default_outputchange = function (self, ind) + end, + set_houtput = function (self, h, ind) if not ind then ind = 1 end self.houtputs[ind] = h + local obj = self.outputs[ind] + if obj then + obj.obj:input_change(obj.ind) + end end, create = function (dcanvas, tab, extra) @@ -398,8 +407,8 @@ dalosp.object = { extra = extra, get_output = tab.getoutput or dalosp.object.default_getoutput, input_change = tab.input_change or dalosp.object.default_inputchange, + output_change = tab.output_change or dalosp.object.default_outputchange, set_houtput = dalosp.object.set_houtput, - get_outputx = nil, houtputs = {}, get_linked_input = dalosp.object.get_linked_input, } @@ -452,20 +461,65 @@ dalosp.hexview = { configure = function (self) end, + output_change = function (self, ind) + end, + + update_houtput = function (self, ind, cursor) + end, + + dalos_hv_cb = function (self, hv, reset) + if reset then + local h, o = self.houtputs + for i = 1, 12 do + self.oldcursors[i] = -1 + end + end + + local m + for i = 1, 10 do + m = hv.markers[i] + if self.oldcursors[i] ~= m then + self:update_houtput(i, m) + self.oldcursors[i] = m + end + end + + m = hv.kcursor + if self.oldcursors[11] ~= m then + self:update_houtput(11, m) + self.oldcursors[11] = m + end + + m = hv.mcursor + if self.oldcursors[12] ~= m then + self:update_houtput(12, m) + self.oldcursors[12] = m + end + end, + create = function (d, tab) if not tab.name then tab.name = "Hexview" end tab.otype = dalos.objtype.LUA_FILTER tab.activate = dalosp.hexview.activate tab.input_change = dalosp.hexview.input_change + tab.output_change = dalosp.hexview.output_change tab.configure = dalosp.hexview.configure tab.ninputs = 1 tab.noutputs = 12 + local hv = iupe.hexview { } local hvtb = iupe.hexview_toolbox { hexview = hv } local hvdlg = iup.dialog { iup.hbox { iup.frame { hv }, iup.sbox { direction = "WEST", hvtb } }, title = tab.name } - return dalos.object(d, tab, { hv = hv, hvtb = hvtb, hvdlg = hvdlg }) + local obj = dalos.object(d, tab, { hv = hv, hvtb = hvtb, hvdlg = hvdlg }) + obj.oldcursors = { } + obj.update_houtput = dalosp.hexview.update_houtput + for i = 1, 12 do obj.oldcursors[i] = -1 end + + hv:registercb(dalosp.hexview.dalos_hv_cb, obj) + + return obj end, } -- cgit v1.2.3