From e294e63159e9596dd23bdb33e6ac3c574c32289f Mon Sep 17 00:00:00 2001 From: Pixel Date: Mon, 21 Dec 2009 21:22:38 +0100 Subject: Various fixes. --- dalos-binaryops.lua | 2 +- dalos-hexview.lua | 17 +++++++++++------ dalos-limiter.lua | 2 +- dalos-luahandle.lua | 2 +- dalos.lua | 8 ++++++-- iupe-hexview.lua | 30 ++++++++++++++++++++++++++++++ 6 files changed, 50 insertions(+), 11 deletions(-) diff --git a/dalos-binaryops.lua b/dalos-binaryops.lua index 022020c..1ced26f 100644 --- a/dalos-binaryops.lua +++ b/dalos-binaryops.lua @@ -45,7 +45,7 @@ Maximize: %b[No,Yes]{Check if you want to maximize the output} offset = 0, size = self.extra.maximize and math.max(h1:getsize(), h2:getsize()) or math.min(h1:getsize(), h2:getsize()), getname = function () return self.name end, - do_read = function (self, dummy, count) + do_read = function (self, count) self.h1:seek(self.offset) self.h2:seek(self.offset) diff --git a/dalos-hexview.lua b/dalos-hexview.lua index a302d39..ee9412e 100644 --- a/dalos-hexview.lua +++ b/dalos-hexview.lua @@ -52,12 +52,16 @@ dalosp.hexview = { 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 maxsixe = h and h:getsize() or -1 - if h and self.watchees[ind] then + 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 @@ -72,7 +76,7 @@ dalosp.hexview = { do_seek = function (self) self.h:seek(self.offset + self.origin) end, - do_read = function (self, userdata, count) + do_read = function (self, count, userdata) return self.h:read(count, userdata) end, } @@ -84,20 +88,20 @@ dalosp.hexview = { local m for i = 1, 10 do m = hv.markers[i] - if self.oldcursors[i] ~= m then + if m and 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 + if m and self.oldcursors[11] ~= m then self:update_houtput(11, m) self.oldcursors[11] = m end m = hv.mcursor - if self.oldcursors[12] ~= m then + if m and self.oldcursors[12] ~= m then self:update_houtput(12, m) self.oldcursors[12] = m end @@ -146,6 +150,7 @@ dalosp.hexview = { end hv:registercb(dalosp.hexview.dalos_hv_cb, obj) + obj.dalos_hv_cb = dalosp.hexview.dalos_hv_cb return obj end, diff --git a/dalos-limiter.lua b/dalos-limiter.lua index ee9b106..99bd07f 100644 --- a/dalos-limiter.lua +++ b/dalos-limiter.lua @@ -21,7 +21,7 @@ Limit: %i{The actual size this limiter is going to produce} h = h, size = math.max(h:getsize(), self.limit), getname = function () return self.name end, - do_read = function (self, userdata, count) + do_read = function (self, count, userdata) return self.h:read(count, userdata) end, do_seek = function (self) diff --git a/dalos-luahandle.lua b/dalos-luahandle.lua index 3254490..332a90e 100644 --- a/dalos-luahandle.lua +++ b/dalos-luahandle.lua @@ -44,7 +44,7 @@ dalosp.luahandle = { for k, v in pairs(tab) do obj[k] = v end local newh = HandleLua(obj) obj.lh = newh - self:set_houtput(newh) + return newh end, } diff --git a/dalos.lua b/dalos.lua index 7f554d1..06058de 100644 --- a/dalos.lua +++ b/dalos.lua @@ -16,6 +16,8 @@ dalosp.WEST = 3 dalosp.EAST = 4 dalosp.cross = { } +dalos.version = { MAJOR = 0, MINOR = 1, suffix = "alpha" } + function dalos:register_obj(name, constructor) if self.objectstypes_by_name[name] then error("An object type of that name already exists: " .. name) @@ -502,7 +504,9 @@ dalosp.menu = { if dlg.status ~= -1 then local s, v = pcall(Output, dlg.value) if s then - v:write "local " + v:write "---- Dalos save\nlocal " + dumpvars(v, dalos.version, "version") + v:write "if dalos.version.MAJOR < version.MAJOR or dalos.version.MAJOR == version.MAJOR and dalos.version.MINOR < version.MINOR then error 'Dalos version too old for this save.' end\n\nlocal " dumpvars(v, save, "save") v:write "return save" end @@ -519,7 +523,7 @@ dalosp.menu = { ButtonDefault = "1", Buttons = "OK", Title = "About", - Value = 'DALOS (c) 2009-2010 Nicolas "Pixel" Noble.\nThis is free software with ABSOLUTELY NO WARRANTY.\nPlease look at the COPYRIGHT file for details.', + Value = 'DALOS ' .. dalos.version.MAJOR .. '.' .. dalos.version.MINOR .. dalos.version.suffix .. ' (c) 2009-2010 Nicolas "Pixel" Noble.\nThis is free software with ABSOLUTELY NO WARRANTY.\nPlease look at the COPYRIGHT file for details.', } dlg:popup() return iup.DEFAULT diff --git a/iupe-hexview.lua b/iupe-hexview.lua index 0567cd0..4b135f0 100644 --- a/iupe-hexview.lua +++ b/iupe-hexview.lua @@ -340,6 +340,36 @@ iupep.hexview = { elseif c == iup.K_m0 then kaction = true self.markers[10] = kcursor + elseif c == iup.K_c1 then + kaction = true + self.markers[1] = nil + elseif c == iup.K_c2 then + kaction = true + self.markers[2] = nil + elseif c == iup.K_c3 then + kaction = true + self.markers[3] = nil + elseif c == iup.K_c4 then + kaction = true + self.markers[4] = nil + elseif c == iup.K_c5 then + kaction = true + self.markers[5] = nil + elseif c == iup.K_c6 then + kaction = true + self.markers[6] = nil + elseif c == iup.K_c7 then + kaction = true + self.markers[7] = nil + elseif c == iup.K_c8 then + kaction = true + self.markers[8] = nil + elseif c == iup.K_c9 then + kaction = true + self.markers[9] = nil + elseif c == iup.K_c0 then + kaction = true + self.markers[10] = nil elseif c == iup.K_SP then kaction = true end -- cgit v1.2.3