diff options
Diffstat (limited to 'iupe-hexview.lua')
-rw-r--r-- | iupe-hexview.lua | 57 |
1 files changed, 50 insertions, 7 deletions
diff --git a/iupe-hexview.lua b/iupe-hexview.lua index 0567cd0..a6817d9 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,14 +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] - if marker ~= -1 then + marker = self.markers[i] or -1 + marker = marker - filecursor + 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 @@ -340,6 +352,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 @@ -491,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, @@ -509,7 +551,6 @@ iupep.hexview = { tab.gridsize = nil tab.cursor = "TEXT" tab.expand = "Yes" - tab.shrink = "Yes" tab.border = "No" tab.minsize = "0x0" tab.size = "0x0" @@ -544,9 +585,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, |