summaryrefslogtreecommitdiff
path: root/dalos-hexview.lua
diff options
context:
space:
mode:
Diffstat (limited to 'dalos-hexview.lua')
-rw-r--r--dalos-hexview.lua49
1 files changed, 43 insertions, 6 deletions
diff --git a/dalos-hexview.lua b/dalos-hexview.lua
index 79f2a08..0ee8a8c 100644
--- a/dalos-hexview.lua
+++ b/dalos-hexview.lua
@@ -32,17 +32,38 @@ dalosp.hexview = {
end,
configure = function (self)
+ local s, newname, gsx, gsy, dgsx, dgsy, dl, ml =
+ iup.GetParam(self.name .. " properties", nil, [[
+Name: %s
+Gridsize X: %i
+Gridsize Y: %i
+Default gridsize X: %i
+Default gridsize Y: %i
+Lines: %i
+Marker lengths: %b
+]],
+ self.name, self.extra.hv.gridsize.x, self.extra.hv.gridsize.y, iupep.hexview.gridsize.x, iupep.hexview.gridsize.y,
+ self.extra.hv.displaylines, self.extra.hv.showmarkerslengths and 1 or 0)
+ if not s then return end
+ self.name = newname
+ self.extra.hv.gridsize.x = gsx
+ self.extra.hv.gridsize.y = gsy
+ iupep.hexview.gridsize.x = dgsx
+ iupep.hexview.gridsize.y = dgsy
+ self.extra.hv.displaylines = dl
+ self.extra.hv.showmarkerslengths = ml == 1
end,
get_settings = function (self)
- local hv = extra.hv
+ local hv = self.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,
+ displaylines = hv.displaylines + 0,
+ gridsize = hv.gridsize,
+ showmarkerslengths = hv.showmarkerslengths,
}
for i = 1, 10 do
r.markers[i] = hv.markers[i] + 0
@@ -51,6 +72,7 @@ dalosp.hexview = {
end,
output_change = function (self, ind)
+ self.extra.hv.markerslengths[ind] = 0
self.watchees[ind] = self.outputs[ind] and true or false
self:set_houtput(nil, ind)
self.oldcursors[ind] = -1
@@ -58,13 +80,16 @@ dalosp.hexview = {
end,
update_houtput = function (self, ind, cursor)
+ local hv = self.extra.hv
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
+ if cursor >= maxsize then
self:set_houtput(nil, ind)
+ return
end
+ h:seek(cursor)
local obj = {
h = h,
hvo = self,
@@ -75,10 +100,21 @@ dalosp.hexview = {
getmodif = function (self) return self.hvo:getmodif() end,
do_seek = function (self)
self.h:seek(self.offset + self.origin)
+ self:post_read()
end,
do_read = function (self, count, userdata)
return self.h:read(count, userdata)
end,
+ post_read = function (self, count)
+ local ol = hv.markerslengths[ind]
+ local nl = self.offset
+ if nl > ol then
+ hv.markerslengths[ind] = nl
+ if hv.showmarkerslengths then
+ hv:draw()
+ end
+ end
+ end,
}
self:set_houtput(dalos.luahandle(obj), ind)
end
@@ -145,8 +181,9 @@ dalosp.hexview = {
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
+ if settings.displaylines then hv.displaylines = settings.displaylines end
+ if settings.gridsize then hv.gridsize.x, hv.gridsize.y = settings.gridsize.x, settings.gridsize.y end
+ if settings.showmarkerslengths then hv.showmarkerslengths = settings.showmarkerslengths end
end
hv:registercb(dalosp.hexview.dalos_hv_cb, obj)