From dc22c96581d74e353b722edd903ee1c5eeb67414 Mon Sep 17 00:00:00 2001 From: Pixel Date: Thu, 24 Dec 2009 19:24:55 +0100 Subject: Adding more hexview configuration items, and adding the ability of the hexviewer to display read limits, somehow. --- iupe-hexview.lua | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'iupe-hexview.lua') diff --git a/iupe-hexview.lua b/iupe-hexview.lua index 1d5f9e3..fb02b68 100644 --- a/iupe-hexview.lua +++ b/iupe-hexview.lua @@ -34,6 +34,8 @@ markercolors = { } iupep.hexview = { + gridsize = { x = 8, y = 14 }, + printgrid = function (self, msg, y, x) local cvdb = self.cvdb if not x then x = self.textcursor.x end @@ -116,15 +118,24 @@ iupep.hexview = { self:colorgrid(cursorcolors.GREEN, 2, kline, kcolumn * 3 + 10) self:colorgrid(cursorcolors.GREEN, 1, kline, kcolumn + 12 + columns * 3) - local marker + local marker, len, mlen for i = 0, 10 do marker = self.markers[i] or -1 marker = marker - filecursor - if marker >= 0 and marker < nbbytes then + mlen = self.markerslengths[i] + if marker >= 0 and self.showmarkerslengths and mlen and mlen > 0 then + len = math.min(mlen, nbbytes - marker) + elseif marker >= 0 and marker < nbbytes then + len = 1 + else + len = 0 + end + for j = 1, len do mline = math.floor(marker / columns) mcolumn = marker % columns self:colorgrid(markercolors[i], 2, mline, mcolumn * 3 + 10) self:colorgrid(markercolors[i], 1, mline, mcolumn + 12 + columns * 3) + marker = marker + 1 end end @@ -522,7 +533,7 @@ iupep.hexview = { end, updategridsize = function (self, gridsize) - self.gridsize = gridsize or { x = 8, y = 14 } + self.gridsize = gridsize or iupep.hexview.gridsize self:resize_cb(self.width, self.height) end, @@ -575,9 +586,11 @@ iupep.hexview = { r.filesize = handle and handle:getsize() or 0 r.mcursor = -1 r.markers = {} - r.displaylines = -1 + r.markerslengths = {} + r.showmarkerslengths = false + r.displaylines = 0 for i = 0, 10 do r.markers[i] = -1 end - r.gridsize = gridsize or { x = 8, y = 14 } + r.gridsize = gridsize or iupep.hexview.gridsize r.textcursor = { x = 0, y = 0 } return r end, -- cgit v1.2.3