diff --git a/filehistory.lua b/filehistory.lua index cf2e5b6db..ca71b3837 100644 --- a/filehistory.lua +++ b/filehistory.lua @@ -220,6 +220,7 @@ function FileHistory:addAllCommands() "delete history entry", function(self) file_entry = self.result[self.perpage*(self.page-1)+self.current] + if not file_entry then return end local file_to_del = file_entry.dir .. "/" .. file_entry.name os.remove(DocToHistory(file_to_del)) -- to avoid showing just deleted file diff --git a/screen.lua b/screen.lua index 2282861c6..9f34322cd 100644 --- a/screen.lua +++ b/screen.lua @@ -146,41 +146,43 @@ a vertical flip that makes it a bit slower, namely, NB: needs free memory of G_width*G_height/2 bytes to manupulate the fb-content! ]] function Screen:fb2bmp(fin, fout, vflip, pack) -- atm, for 4bpp framebuffers only - local inputf = assert(io.open(fin,"rb")) + local inputf = io.open(fin,"rb") if inputf then - local outputf, size = assert(io.open(fout,"wb")) - -- writing bmp-header - outputf:write(string.char(0x42,0x4D,0xF6,0xA9,3,0,0,0,0,0,0x76,0,0,0,40,0), - self:LE(G_width), self:LE(G_height), -- width & height: 4 chars each - string.char(0,0,1,0,4,0,0,0,0,0), - self:LE(G_height*G_width/2), -- raw bytes in image - string.char(0x87,0x19,0,0,0x87,0x19,0,0), -- 6536 pixel/m = 166 dpi for both x&y resolutions - string.char(16,0,0,0,0,0,0,0)) -- 16 colors - local line, i = G_width/2, 15 - -- add palette to bmp-header - while i>=0 do - outputf:write(string.char(i*16+i):rep(3), string.char(0)) - i=i-1 - end - if vflip then -- flip image vertically to make it bmp-compliant - -- read the fb-content line-by-line & fill the content-table in the inversed order - local content = {} - for i=1, G_height do - table.insert(content, 1, inputf:read(line)) + local outputf, size = io.open(fout,"wb") + if outputf then + -- writing bmp-header + outputf:write(string.char(0x42,0x4D,0xF6,0xA9,3,0,0,0,0,0,0x76,0,0,0,40,0), + self:LE(G_width), self:LE(G_height), -- width & height: 4 chars each + string.char(0,0,1,0,4,0,0,0,0,0), + self:LE(G_height*G_width/2), -- raw bytes in image + string.char(0x87,0x19,0,0,0x87,0x19,0,0), -- 6536 pixel/m = 166 dpi for both x&y resolutions + string.char(16,0,0,0,0,0,0,0)) -- 16 colors + local line, i = G_width/2, 15 + -- add palette to bmp-header + while i>=0 do + outputf:write(string.char(i*16+i):rep(3), string.char(0)) + i=i-1 end - -- write the v-flipped bmp-data - for i=1, G_height do - outputf:write(content[i]) + if vflip then -- flip image vertically to make it bmp-compliant + -- read the fb-content line-by-line & fill the content-table in the inversed order + local content = {} + for i=1, G_height do + table.insert(content, 1, inputf:read(line)) + end + -- write the v-flipped bmp-data + for i=1, G_height do + outputf:write(content[i]) + end + else -- without v-flip, it takes only 0.02s @ 600x800, 4bpp + outputf:write(inputf:read("*all")) end - else -- without v-flip, it takes only 0.02s @ 600x800, 4bpp - outputf:write(inputf:read("*all")) - end + outputf:close() + -- here one may use either standard archivers (bzip2, gzip) + -- or standalone converters (bmp2png, bmp2gif) + if pack then os.execute(pack..fout) end + end -- if output f inputf:close() - outputf:close() - -- here one may use either standard archivers (bzip2, gzip) - -- or standalone converters (bmp2png, bmp2gif) - if pack then os.execute(pack..fout) end - end + end -- if inputf end --[[ This function saves the fb-content (both 4bpp and 8bpp) as 8bpp PGM and pack it. diff --git a/unireader.lua b/unireader.lua index ed8393e16..933772603 100644 --- a/unireader.lua +++ b/unireader.lua @@ -2261,7 +2261,13 @@ function UniReader:addAllCommands() "go backward in jump history", function(unireader) local prev_jump_no = 0 + local need_refresh = false if unireader.jump_history.cur > #unireader.jump_history then + -- addJump() will cause a "Retrieving TOC..." msg, so we'll + -- need to redraw the page after our own + -- ifo msg "Already first jump!" below + if not self.toc then need_refresh = true end + -- if cur points to head, put current page in history unireader:addJump(self.pageno) prev_jump_no = unireader.jump_history.cur - 2 @@ -2274,6 +2280,9 @@ function UniReader:addAllCommands() unireader:goto(unireader.jump_history[prev_jump_no].page, true) else showInfoMsgWithDelay("Already first jump!", 2000, 1) + if need_refresh then + unireader:redrawCurrentPage() + end end end) self.commands:add(KEY_BACK,MOD_SHIFT,"Back",