diff options
| -rw-r--r-- | dalos-hexview.lua | 2 | ||||
| -rw-r--r-- | dalos-struct.lua | 64 | ||||
| -rw-r--r-- | dalos-textview.lua | 1 | 
3 files changed, 57 insertions, 10 deletions
| diff --git a/dalos-hexview.lua b/dalos-hexview.lua index 0ee8a8c..28d7217 100644 --- a/dalos-hexview.lua +++ b/dalos-hexview.lua @@ -97,7 +97,7 @@ Marker lengths: %b                  origin = cursor,                  size = maxsize - cursor,                  getname = function (self) return self.hvo.name .. ":" .. self.ind end, -                getmodif = function (self) return self.hvo:getmodif() end, +                getmodif = function (self) return self.h:getmodif() end,                  do_seek = function (self)                      self.h:seek(self.offset + self.origin)                      self:post_read() diff --git a/dalos-struct.lua b/dalos-struct.lua index 84e9699..9bbe617 100644 --- a/dalos-struct.lua +++ b/dalos-struct.lua @@ -64,7 +64,8 @@ dalosp.struct = {      input_change = function (self, ind)          if ind == 1 then self:update_values() end          if ind == 2 then -             +            local h = self:get_linked_input(2) +            self:auto_template(dalosp.struct.templates, h:readstring())          end      end, @@ -136,10 +137,7 @@ dalosp.struct = {                  self.extra.values_by_name[f.name] = v              end              self:output_selected() -            local b = Buffer(true) -             -            ---- filling in the output structure in b -            self:set_houtput(b, 2) +            self:output_struct()          else              self:set_houtput(nil, 1)              self:set_houtput(nil, 2) @@ -147,6 +145,43 @@ dalosp.struct = {      end,      output_selected = function (self) +        local selected = self.extra.selected +        local cache = self.extra.cache +        local cursor = selected and cache[selected] or -1 +        local h = self:get_linked_input(1) +        if h and selected and selected > 0 and cursor >= 0 then +            local field = self.extra.entries[selected].name +            local maxsize = (cache[selected + 1] or self.extra.size) - cursor +            h:seek(cursor) +            local obj = { +                h = h, +                str = self, +                origin = cursor, +                field = field, +                size = maxsize - cursor, +                getname = function (self) return self.str.name .. ":" .. self.field end, +                getmodif = function (self) return self.h:getmodif() end, +                do_seek = function (self) +                    self.h:seek(self.offset + self.origin) +                end, +                do_read = function (self, count, userdata) +                    return self.h:read(count, userdata) +                end, +            } +            self:set_houtput(dalos.luahandle(obj), 1) +            local b = Buffer(true) +            b:write(field .. "\n") +            self:set_houtput(b, 3) +        else +            self:set_houtput(nil, 1) +            self:set_houtput(nil, 3) +        end +    end, +     +    output_struct = function (self) +        local b = Buffer(true) +        dumpvars(b, self.extra.values_by_name, "data") +        self:set_houtput(b, 2)      end,      cacheoffset = function (self) @@ -346,6 +381,8 @@ dalosp.struct = {          if col == 5 then              entries[lin].name = newval +            self.struct:output_selected() +            self.struct:output_struct()          elseif col == 6 then              entries[lin].type = dalosp.struct.rtypes[newval]              self.struct:cacheoffset() @@ -413,7 +450,8 @@ dalosp.struct = {      end,      act_click_cb = function (self, lin, col, status) -         +        self.struct.extra.selected = lin +        self.struct:output_selected()      end,      create = function (d, tab, settings) @@ -432,7 +470,8 @@ dalosp.struct = {          local extra = { }          if not settings then settings = {} end -        extra.entries = settings.entries or {} +        local entries = settings.entries or {} +        extra.entries = entries          local obj = dalos.object(d, tab, extra) @@ -450,8 +489,7 @@ dalosp.struct = {          obj.update_values = dalosp.struct.update_values          obj.read_value = dalosp.struct.read_value          obj.output_selected = dalosp.struct.output_selected -         -        obj:cacheoffset() +        obj.output_struct = dalosp.struct.output_struct          local cmx = iup.matrix {              numcol = 11, @@ -535,6 +573,14 @@ dalosp.struct = {              title = obj.name,          } +        if entries then +            obj.cfg_dlg.mx.numlin = #entries +            obj.cfg_dlg.mx.numlin_visible = #entries +            obj.act_dlg.mx.numlin = #entries +            obj.act_dlg.mx.numlin_visible = #entries +        end +        obj:cacheoffset() +                  return obj      end, diff --git a/dalos-textview.lua b/dalos-textview.lua index 496fd26..2a0e220 100644 --- a/dalos-textview.lua +++ b/dalos-textview.lua @@ -34,6 +34,7 @@ dalosp.textview = {              multiline = "Yes",              readonly = "Yes",              expand = "Yes", +            shrink = "Yes",              font = "Courier, 8"          }          local dlg = iup.dialog { | 
