diff options
| -rw-r--r-- | dalos.lua | 72 | ||||
| -rw-r--r-- | iupe-hexview-toolbox.lua | 7 | ||||
| -rw-r--r-- | iupe-hexview.lua | 3 | 
3 files changed, 54 insertions, 28 deletions
| @@ -328,6 +328,17 @@ dalosp.object = {          end      end, +    get_linked_input = function (self, ind) +        local ni = self.inputs[ind] +        if ni then +            local ii = ni.ind +            local io = ni.obj +            return io.obj:get_output(ii) +        else +            return nil +        end +    end, +          default_activate = function (self)          print "activate"      end, @@ -390,6 +401,7 @@ dalosp.object = {              set_houtput = dalosp.object.set_houtput,              get_outputx = nil,              houtputs = {}, +            get_linked_input = dalosp.object.get_linked_input,          }          if tab.otype and not tab.c then @@ -426,6 +438,41 @@ dalos.objtype = {  ---------------- +dalosp.hexview = { +    activate = function (self) +        self.extra.hvdlg:show() +    end, +     +    input_change = function (self, ind) +        local extra = self.extra +        local hv = extra.hv +        hv:updatehandle(self:get_linked_input(ind)) +    end, +     +    configure = function (self) +    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.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 }) +    end, +} + +dalos.hexview = dalosp.hexview.create + +---------------- +  d = dalos.canvas {}  m = dalos.menu {} @@ -434,32 +481,9 @@ b1:write("Buffer 1 contents")  b2 = Buffer(true)  b2:write("Buffer 2 contents") -function activate_hv(self) -    self.extra.hvdlg:show() -end - -function input_change_hv(self, ind) -    local ni = self.inputs[ind] -    if ni then -        local ii = ni.ind -        local io = ni.obj -        self.extra.hv:updatehandle(io.obj:get_output(ii)) -    else -        self.extra.hv:updatehandle(nil) -    end -end - -hv = iupe.hexview { } -hvdlg = iup.dialog { iup.hbox{ iup.frame { hv }, iup.sbox { direction = "WEST", iupe.hexview_toolbox { hexview = hv, }, }, }, title = "Hexview" } - -extra = { -    hv = hv, -    hvdlg = hvdlg, -} -  o1 = dalos.object(d, { y = 30, x = 10, noutputs = 1, name = "Buffer 1", otype = dalos.objtype.HANDLE })  o2 = dalos.object(d, { y = 120, x = 10, noutputs = 1, name = "Buffer 2", otype = dalos.objtype.HANDLE }) -h = dalos.object(d, { y = 60, x = 100, ninputs = 1, name = "Hexview", otype = dalos.objtype.LUA_VIEWER, activate = activate_hv, input_change = input_change_hv }, extra) +h = dalos.hexview(d, { y = 60, x = 100 })  o1:set_houtput(b1)  o2:set_houtput(b2) diff --git a/iupe-hexview-toolbox.lua b/iupe-hexview-toolbox.lua index 7cfb7a4..fdb2638 100644 --- a/iupe-hexview-toolbox.lua +++ b/iupe-hexview-toolbox.lua @@ -22,7 +22,7 @@ iupep.hexview_toolbox = {          return r + 0, markercolors[rcursor]      end, -    hexview_cb = function (self, hexview) +    hexview_cb = function (self, hexview, reset)          local filecursor = hexview.filecursor          local filesize = hexview.filesize          local fcl = self.cursors.file @@ -34,7 +34,7 @@ iupep.hexview_toolbox = {          local cursor, bgcolor = self:getcursor(hexview)          local oldcursor = self.oldcursor + 0 -        if oldcursor == cursor or cursor == -1 then return iup.DEFAULT end +        if not reset and (oldcursor == cursor or cursor == -1) then return iup.DEFAULT end          self.oldcursor = cursor          local cl = self.cursors.normal          cl.dec.title = cursor @@ -242,8 +242,7 @@ iupep.hexview_toolbox = {          end          function endianess:action(text, pos, state) -            r.oldcursor = -1 -            r:hexview_cb(hexview) +            r:hexview_cb(hexview, true)          end          cursorlabel_dec.action = function (self) return iupep.hexview_toolbox.cursor_change(self, hexview, r, false) end diff --git a/iupe-hexview.lua b/iupe-hexview.lua index 12ec90c..0567cd0 100644 --- a/iupe-hexview.lua +++ b/iupe-hexview.lua @@ -370,6 +370,9 @@ iupep.hexview = {          self.old_filecursor = -1          self:updatescrollbar()          self:draw() +        for _, v in ipairs(self.cbs) do +            v.cb(v.opaque, self, true) +        end      end,      map_cb = function (self) | 
