diff options
author | Pixel <pixel@nobis-crew.org> | 2009-12-23 00:11:30 +0100 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2009-12-23 00:11:30 +0100 |
commit | f6ac50837aabd69c6ea5892a858359f51f40ee03 (patch) | |
tree | fd6f7007d543de2cca7a813e8efbf156089aa0eb /dalos-hexview.lua | |
parent | 95b71cfc474f247e7e1081ea67c7a2166ddd3805 (diff) |
Mbmbmlmlm \r is evil.
Diffstat (limited to 'dalos-hexview.lua')
-rw-r--r-- | dalos-hexview.lua | 320 |
1 files changed, 160 insertions, 160 deletions
diff --git a/dalos-hexview.lua b/dalos-hexview.lua index a4915f4..cfd8652 100644 --- a/dalos-hexview.lua +++ b/dalos-hexview.lua @@ -1,160 +1,160 @@ -load "iupe-hexview.lua"
-load "iupe-hexview-toolbox.lua"
-
-dalosp.hexview = {
- activate = function (self)
- self.extra.hvdlg:show()
- end,
-
- input_change = function (self, ind)
- local extra = self.extra
- local hv = extra.hv
- local h = self:get_linked_input(ind)
- if not h then
- self.color = cd.YELLOW
- hv:updatehandle(nil)
- self.dcanvas:draw()
- return
- end
- if not h:canread() or not h:canseek() then
- self.color = cd.RED
- hv:updatehandle(nil)
- self.dcanvas:draw()
- return
- end
- self.color = cd.GREEN
- for i = 1, 12 do
- self:set_houtput(nil, i)
- self.oldcursors[i] = -1
- end
- hv:updatehandle(h)
- self.dcanvas:draw()
- end,
-
- configure = function (self)
- end,
-
- get_settings = function (self)
- local hv = extra.hv
- local r = {
- mcursor = hv.mcursor + 0,
- kcursor = hv.kcursor + 0,
- markers = {},
- filecursor = hv.filecursor + 0,
- nbbytes = hv.nbbytes + 0,
- nblines = hv.nblines + 0,
- }
- for i = 1, 10 do
- r.markers[i] = hv.markers[i] + 0
- end
- return r
- end,
-
- output_change = function (self, ind)
- self.watchees[ind] = self.outputs[ind] and true or false
- self:set_houtput(nil, ind)
- self.oldcursors[ind] = -1
- self:dalos_hv_cb(self.extra.hv)
- end,
-
- update_houtput = function (self, ind, cursor)
- local h = self:get_linked_input(1)
- local maxsize = h and h:getsize() or -1
- cursor = cursor + 0
- if cursor >= 0 and h and self.watchees[ind] then
- if cursor < maxsize then
- self:set_houtput(nil, ind)
- end
- local obj = {
- h = h,
- hvo = self,
- ind = ind,
- origin = cursor,
- size = maxsize - cursor,
- getname = function (self) return self.hvo.name .. ":" .. self.ind end,
- getmodif = function (self) return self.hvo: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), ind)
- end
- end,
-
- dalos_hv_cb = function (self, hv, reset)
- local m
- for i = 1, 10 do
- m = hv.markers[i]
- if m and self.oldcursors[i] ~= m then
- self:update_houtput(i, m)
- self.oldcursors[i] = m
- end
- end
-
- m = hv.kcursor
- if m and self.oldcursors[11] ~= m then
- self:update_houtput(11, m)
- self.oldcursors[11] = m
- end
-
- m = hv.mcursor
- if m and self.oldcursors[12] ~= m then
- self:update_houtput(12, m)
- self.oldcursors[12] = m
- end
- end,
-
- create = function (d, tab, settings)
- 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.get_settings = dalosp.hexview.get_settings
- tab.ninputs = 1
- tab.noutputs = 12
- tab.default_name = "Hexview"
- tab.ntype = "Hexview"
-
- local extra = { }
-
- local obj = dalos.object(d, tab, extra)
-
- 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 = obj.name, size = "500x" }
-
- extra.hv = hv
- extra.hvtb = hvtb
- extra.hvdlg = hvdlg
-
- obj.oldcursors = { }
- obj.watchees = { }
- obj.update_houtput = dalosp.hexview.update_houtput
- for i = 1, 12 do obj.oldcursors[i] = -1 end
-
- if settings then
- if settings.markers then
- for i = 1, 10 do
- if settings.markers[i] then hv.markers[i] = settings.markers[i] end
- end
- end
- 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)
- obj.dalos_hv_cb = dalosp.hexview.dalos_hv_cb
-
- return obj
- end,
-}
-
-dalos.hexview = dalosp.hexview.create
-dalos:register_obj("Hexview", dalos.hexview)
+load "iupe-hexview.lua" +load "iupe-hexview-toolbox.lua" + +dalosp.hexview = { + activate = function (self) + self.extra.hvdlg:show() + end, + + input_change = function (self, ind) + local extra = self.extra + local hv = extra.hv + local h = self:get_linked_input(ind) + if not h then + self.color = cd.YELLOW + hv:updatehandle(nil) + self.dcanvas:draw() + return + end + if not h:canread() or not h:canseek() then + self.color = cd.RED + hv:updatehandle(nil) + self.dcanvas:draw() + return + end + self.color = cd.GREEN + for i = 1, 12 do + self:set_houtput(nil, i) + self.oldcursors[i] = -1 + end + hv:updatehandle(h) + self.dcanvas:draw() + end, + + configure = function (self) + end, + + get_settings = function (self) + local hv = extra.hv + local r = { + mcursor = hv.mcursor + 0, + kcursor = hv.kcursor + 0, + markers = {}, + filecursor = hv.filecursor + 0, + nbbytes = hv.nbbytes + 0, + nblines = hv.nblines + 0, + } + for i = 1, 10 do + r.markers[i] = hv.markers[i] + 0 + end + return r + end, + + output_change = function (self, ind) + self.watchees[ind] = self.outputs[ind] and true or false + self:set_houtput(nil, ind) + self.oldcursors[ind] = -1 + self:dalos_hv_cb(self.extra.hv) + end, + + update_houtput = function (self, ind, cursor) + local h = self:get_linked_input(1) + local maxsize = h and h:getsize() or -1 + cursor = cursor + 0 + if cursor >= 0 and h and self.watchees[ind] then + if cursor < maxsize then + self:set_houtput(nil, ind) + end + local obj = { + h = h, + hvo = self, + ind = ind, + origin = cursor, + size = maxsize - cursor, + getname = function (self) return self.hvo.name .. ":" .. self.ind end, + getmodif = function (self) return self.hvo: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), ind) + end + end, + + dalos_hv_cb = function (self, hv, reset) + local m + for i = 1, 10 do + m = hv.markers[i] + if m and self.oldcursors[i] ~= m then + self:update_houtput(i, m) + self.oldcursors[i] = m + end + end + + m = hv.kcursor + if m and self.oldcursors[11] ~= m then + self:update_houtput(11, m) + self.oldcursors[11] = m + end + + m = hv.mcursor + if m and self.oldcursors[12] ~= m then + self:update_houtput(12, m) + self.oldcursors[12] = m + end + end, + + create = function (d, tab, settings) + 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.get_settings = dalosp.hexview.get_settings + tab.ninputs = 1 + tab.noutputs = 12 + tab.default_name = "Hexview" + tab.ntype = "Hexview" + + local extra = { } + + local obj = dalos.object(d, tab, extra) + + 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 = obj.name, size = "500x" } + + extra.hv = hv + extra.hvtb = hvtb + extra.hvdlg = hvdlg + + obj.oldcursors = { } + obj.watchees = { } + obj.update_houtput = dalosp.hexview.update_houtput + for i = 1, 12 do obj.oldcursors[i] = -1 end + + if settings then + if settings.markers then + for i = 1, 10 do + if settings.markers[i] then hv.markers[i] = settings.markers[i] end + end + end + 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) + obj.dalos_hv_cb = dalosp.hexview.dalos_hv_cb + + return obj + end, +} + +dalos.hexview = dalosp.hexview.create +dalos:register_obj("Hexview", dalos.hexview) |