diff --git a/commands.lua b/commands.lua index b932bac58..2168fb57d 100644 --- a/commands.lua +++ b/commands.lua @@ -56,7 +56,7 @@ function Command:new(keydef, func, help, keygroup, order) obj.help = help obj.keygroup = keygroup obj.order = order - --print("creating command: ["..tostring(keydef).."] keygroup:["..(keygroup or "").."] help:"..help) + --debug("creating command: ["..tostring(keydef).."] keygroup:["..(keygroup or "").."] help:"..help) return obj end diff --git a/crereader.lua b/crereader.lua index c197cf2aa..e53639504 100644 --- a/crereader.lua +++ b/crereader.lua @@ -21,7 +21,7 @@ function CREReader:init() for _k, _v in ipairs(fonts) do local ok, err = pcall(cre.registerFont, Font.fontdir..'/'.._v) if not ok then - print(err) + debug(err) end end end @@ -126,7 +126,7 @@ function CREReader:goto(pos, is_ignore_jump, pos_type) self.doc:drawCurrentPage(self.nulldc, fb.bb) - print("## self.show_overlap "..self.show_overlap) + debug("## self.show_overlap "..self.show_overlap) if self.show_overlap < 0 then fb.bb:dimRect(0,0, width, -self.show_overlap) elseif self.show_overlap > 0 then @@ -135,11 +135,11 @@ function CREReader:goto(pos, is_ignore_jump, pos_type) self.show_overlap = 0 if self.rcount == self.rcountmax then - print("full refresh") + debug("full refresh") self.rcount = 1 fb:refresh(0) else - print("partial refresh") + debug("partial refresh") self.rcount = self.rcount + 1 fb:refresh(1) end @@ -240,6 +240,7 @@ function CREReader:showBookMarks() end end + ---------------------------------------------------- -- TOC related methods ---------------------------------------------------- @@ -320,7 +321,7 @@ function CREReader:adjustCreReaderCommands() self.line_space_percent = 200 end InfoMessage:show("line spacing "..self.line_space_percent.."%", 0) - print("line spacing set to", self.line_space_percent) + debug("line spacing set to", self.line_space_percent) cr.doc:setDefaultInterlineSpace(self.line_space_percent) cr:redrawCurrentPage() end @@ -333,7 +334,7 @@ function CREReader:adjustCreReaderCommands() self.line_space_percent = 100 end InfoMessage:show("line spacing "..self.line_space_percent.."%", 0) - print("line spacing set to", self.line_space_percent) + debug("line spacing set to", self.line_space_percent) cr.doc:setDefaultInterlineSpace(self.line_space_percent) cr:redrawCurrentPage() end @@ -345,7 +346,7 @@ function CREReader:adjustCreReaderCommands() self.commands:addGroup("[1..0]", numeric_keydefs, "jump to *10% of document", function(cr, keydef) - print('jump to position: '.. + debug('jump to position: '.. math.floor(cr.doc:getFullHeight()*(keydef.keycode-KEY_1)/9).. '/'..cr.doc:getFullHeight()) cr:goto(math.floor(cr.doc:getFullHeight()*(keydef.keycode-KEY_1)/9)) @@ -364,7 +365,7 @@ function CREReader:adjustCreReaderCommands() } local item_no = fonts_menu:choose(0, G_height) - print(face_list[item_no]) + debug(face_list[item_no]) if item_no then cr.doc:setFontFace(face_list[item_no]) self.font_face = face_list[item_no] diff --git a/dialog.lua b/dialog.lua index 6f0b3850f..023136ae8 100644 --- a/dialog.lua +++ b/dialog.lua @@ -6,7 +6,7 @@ InfoMessage = { } function InfoMessage:show(text,refresh_mode) - print("# InfoMessage ", text, refresh_mode) + debug("# InfoMessage ", text, refresh_mode) local dialog = CenterContainer:new({ dimen = { w = G_width, h = G_height }, FrameContainer:new({ @@ -50,7 +50,6 @@ function showInfoMsgWithDelay(text, msec, refresh_mode) ev = input.waitForEvent(msec*1000) adjustKeyEvents(ev) end) - print(is_not_timeout) until not ok or ev.value == EVENT_VALUE_KEY_PRESS Screen:restoreFromSavedBB() diff --git a/filechooser.lua b/filechooser.lua index a6c2c2ab6..15c2a412e 100644 --- a/filechooser.lua +++ b/filechooser.lua @@ -40,7 +40,7 @@ function getAbsolutePath(aPath) abs_path = lfs.currentdir() lfs.chdir(curr_dir) end - --print("rel: '"..aPath.."' abs:'"..abs_path.."'") + --debug("rel: '"..aPath.."' abs:'"..abs_path.."'") end return abs_path end @@ -50,7 +50,7 @@ function FileChooser:readDir() self.files = {} for f in lfs.dir(self.path) do if lfs.attributes(self.path.."/"..f, "mode") == "directory" and f ~= "." and not (f==".." and self.path=="/") and not string.match(f, "^%.[^.]") then - --print(self.path.." -> adding: '"..f.."'") + --debug(self.path.." -> adding: '"..f.."'") table.insert(self.dirs, f) else local file_type = string.lower(string.match(f, ".+%.([^.]+)") or "") @@ -73,7 +73,7 @@ function FileChooser:setPath(newPath) self.path = getAbsolutePath(newPath) local readdir_ok, exc = pcall(self.readDir,self) if(not readdir_ok) then - print("readDir error: "..tostring(exc)) + debug("readDir error: "..tostring(exc)) self.exception_message = exc return self:setPath(curr_path) else @@ -166,7 +166,7 @@ function FileChooser:choose(ypos, height) end local ev = input.saveWaitForEvent() - --print("key code:"..ev.code) + --debug("key code:"..ev.code) ev.code = adjustKeyEvents(ev) if ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_PRESS then if ev.code == KEY_FW_UP then diff --git a/filesearcher.lua b/filesearcher.lua index 69890e382..fb80fcc5e 100644 --- a/filesearcher.lua +++ b/filesearcher.lua @@ -42,7 +42,7 @@ function FileSearcher:readDir() or file_type == "fb2" or file_type == "chm" then file_entry = {dir=d, name=f,} table.insert(self.files, file_entry) - --print("file:"..d.."/"..f) + --debug("file:"..d.."/"..f) end end end @@ -294,14 +294,14 @@ function FileSearcher:choose(keywords) ev.code = adjustKeyEvents(ev) if ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_PRESS then keydef = Keydef:new(ev.code, getKeyModifier()) - print("key pressed: "..tostring(keydef)) + debug("key pressed: "..tostring(keydef)) command = self.commands:getByKeydef(keydef) if command ~= nil then - print("command to execute: "..tostring(command)) + debug("command to execute: "..tostring(command)) ret_code = command.func(self, keydef) else - print("command not found: "..tostring(command)) + debug("command not found: "..tostring(command)) end if ret_code == "break" then @@ -309,7 +309,7 @@ function FileSearcher:choose(keywords) end if self.selected_item ~= nil then - print("# selected "..self.selected_item) + debug("# selected "..self.selected_item) return self.selected_item end end -- if diff --git a/font.lua b/font.lua index 1518138a8..d294d8bf4 100644 --- a/font.lua +++ b/font.lua @@ -53,11 +53,11 @@ function Font:getFace(font, size) realname = self.fontdir.."/"..realname ok, face = pcall(freetype.newFace, realname, size) if not ok then - print("#! Font "..font.." ("..realname..") not supported: "..face) + debug("#! Font "..font.." ("..realname..") not supported: "..face) return nil end self.faces[font..size] = face - --print("getFace, found: "..realname.." size:"..size) + --debug("getFace, found: "..realname.." size:"..size) end return { size = size, ftface = face, hash = font..size } end diff --git a/helppage.lua b/helppage.lua index 7cd8269d4..89691a76d 100644 --- a/helppage.lua +++ b/helppage.lua @@ -39,7 +39,7 @@ function HelpPage:show(ypos, height, commands) local keys = {} for k,v in pairs(commands.map) do local key = v.keygroup or v.keydef:display() - --print("order: "..v.order.." command: "..tostring(v.keydef).." - keygroup:"..(v.keygroup or "nil").." -keys[key]:"..(keys[key] or "nil")) + --debug("order: "..v.order.." command: "..tostring(v.keydef).." - keygroup:"..(v.keygroup or "nil").." -keys[key]:"..(keys[key] or "nil")) if keys[key] == nil then keys[key] = 1 table.insert(self.commands,{shortcut=key,help=v.help,order=v.order}) @@ -51,8 +51,8 @@ function HelpPage:show(ypos, height, commands) local face_height, face_ascender = self.face.ftface:getHeightAndAscender() --local hface_height, hface_ascender = self.hface.ftface:getHeightAndAscender() local fface_height, fface_ascender = self.fface.ftface:getHeightAndAscender() - --print(face_height.."-"..face_ascender) - --print(fface_height.."-"..fface_ascender) + --debug(face_height.."-"..face_ascender) + --debug(fface_height.."-"..fface_ascender) face_height = math.ceil(face_height) face_ascender = math.ceil(face_ascender) fface_height = math.ceil(fface_height) @@ -74,7 +74,7 @@ function HelpPage:show(ypos, height, commands) local key = self.commands[i].shortcut for _k,aMod in pairs(MOD_TABLE) do local modStart, modEnd = key:find(aMod.v) - print("key:"..key.." v:"..aMod.v.." d:"..aMod.d.." modstart:"..(modStart or "nil")) + debug("key:"..key.." v:"..aMod.v.." d:"..aMod.d.." modstart:"..(modStart or "nil")) if(modStart ~= nil) then key = key:sub(1,modStart-1)..key:sub(modEnd+1) local box = sizeUtf8Text( x, fb.bb:getWidth(), self.face, aMod.d, true) @@ -84,7 +84,7 @@ function HelpPage:show(ypos, height, commands) max_x = math.max(max_x, pen_x) end end - print("key:"..key) + debug("key:"..key) local box = sizeUtf8Text( x, fb.bb:getWidth(), self.face, key , true) fb.bb:paintRect(x, ypos + spacing*c - box.y_top, box.x, box.y_top + box.y_bottom, 4) local pen_x = renderUtf8Text(fb.bb, x, ypos + spacing*c, self.face, key, true) @@ -107,7 +107,7 @@ function HelpPage:show(ypos, height, commands) end local ev = input.saveWaitForEvent() - --print("key code:"..ev.code) + --debug("key code:"..ev.code) ev.code = adjustKeyEvents(ev) if ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_PRESS then if ev.code == KEY_PGFWD then diff --git a/inputbox.lua b/inputbox.lua index 7359f3ef5..1aca2462d 100644 --- a/inputbox.lua +++ b/inputbox.lua @@ -174,14 +174,14 @@ function InputBox:input(ypos, height, title, d_text) ev.code = adjustKeyEvents(ev) if ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_PRESS then keydef = Keydef:new(ev.code, getKeyModifier()) - print("key pressed: "..tostring(keydef)) + debug("key pressed: "..tostring(keydef)) command = self.commands:getByKeydef(keydef) if command ~= nil then - print("command to execute: "..tostring(command)) + debug("command to execute: "..tostring(command)) ret_code = command.func(self, keydef) else - print("command not found: "..tostring(command)) + debug("command not found: "..tostring(command)) end if ret_code == "break" then diff --git a/keys.lua b/keys.lua index 14f41ee8a..849300754 100644 --- a/keys.lua +++ b/keys.lua @@ -254,7 +254,7 @@ function adjustKeyEvents(ev) end end -- This should not happen. - print("# Unrecognizable rotation mode "..Screen.cur_rotation_mode.."!") + debug("# Unrecognizable rotation mode "..Screen.cur_rotation_mode.."!") return nil end @@ -264,7 +264,7 @@ function input.saveWaitForEvent(timeout) while retry do local ok, ev = pcall(input.waitForEvent, timeout) if not ok then - print("got error waiting for events:", ev) + debug("got error waiting for events:", ev) if ev == "Waiting for input failed: 4\n" then -- EINTR, we got interrupted. Try and restart retry = true diff --git a/pdfreader.lua b/pdfreader.lua index 4c2772104..4d8ab1142 100644 --- a/pdfreader.lua +++ b/pdfreader.lua @@ -41,7 +41,7 @@ function PDFReader:getText(pageno) return nil end local text = page:getPageText() - --print("## page:getPageText "..dump(text)) -- performance impact on device + --debug("## page:getPageText "..dump(text)) -- performance impact on device page:close() return text end diff --git a/reader.lua b/reader.lua index 2a1d882b3..646cc8b35 100755 --- a/reader.lua +++ b/reader.lua @@ -100,7 +100,6 @@ else -- check if we are running on Kindle 3 (additional volume input) local f=lfs.attributes("/dev/input/event2") - print(f) if f then print("Auto-detected Kindle 3") input.open("/dev/input/event2") diff --git a/rendertext.lua b/rendertext.lua index 320f7dd41..3df48ae14 100644 --- a/rendertext.lua +++ b/rendertext.lua @@ -46,7 +46,7 @@ end function sizeUtf8Text(x, width, face, text, kerning) if text == nil then - print("# sizeUtf8Text called without text"); + debug("# sizeUtf8Text called without text"); return end -- may still need more adaptive pen placement when kerning, @@ -55,7 +55,6 @@ function sizeUtf8Text(x, width, face, text, kerning) local pen_y_top = 0 local pen_y_bottom = 0 local prevcharcode = 0 - --print("----------------- text:"..text) for uchar in string.gfind(text, "([%z\1-\127\194-\244][\128-\191]*)") do if pen_x < (width - x) then local charcode = util.utf8charcode(uchar) @@ -63,14 +62,14 @@ function sizeUtf8Text(x, width, face, text, kerning) if kerning and prevcharcode then local kern = face.ftface:getKerning(prevcharcode, charcode) pen_x = pen_x + kern - --print("prev:"..string.char(prevcharcode).." curr:"..string.char(charcode).." kern:"..kern) + --debug("prev:"..string.char(prevcharcode).." curr:"..string.char(charcode).." kern:"..kern) else - --print("curr:"..string.char(charcode)) + --debug("curr:"..string.char(charcode)) end pen_x = pen_x + glyph.ax pen_y_top = math.max(pen_y_top, glyph.t) pen_y_bottom = math.max(pen_y_bottom, glyph.bb:getHeight() - glyph.t) - --print("ax:"..glyph.ax.." t:"..glyph.t.." r:"..glyph.r.." h:"..glyph.bb:getHeight().." w:"..glyph.bb:getWidth().." yt:"..pen_y_top.." yb:"..pen_y_bottom) + --debug("ax:"..glyph.ax.." t:"..glyph.t.." r:"..glyph.r.." h:"..glyph.bb:getHeight().." w:"..glyph.bb:getWidth().." yt:"..pen_y_top.." yb:"..pen_y_bottom) prevcharcode = charcode end end @@ -79,7 +78,7 @@ end function renderUtf8Text(buffer, x, y, face, text, kerning) if text == nil then - print("# renderUtf8Text called without text"); + debug("# renderUtf8Text called without text"); return 0 end -- may still need more adaptive pen placement when kerning, @@ -93,10 +92,10 @@ function renderUtf8Text(buffer, x, y, face, text, kerning) if kerning and prevcharcode then local kern = face.ftface:getKerning(prevcharcode, charcode) pen_x = pen_x + kern - --print("prev:"..string.char(prevcharcode).." curr:"..string.char(charcode).." pen_x:"..pen_x.." kern:"..kern) + --debug("prev:"..string.char(prevcharcode).." curr:"..string.char(charcode).." pen_x:"..pen_x.." kern:"..kern) buffer:addblitFrom(glyph.bb, x + pen_x + glyph.l, y - glyph.t, 0, 0, glyph.bb:getWidth(), glyph.bb:getHeight()) else - --print(" curr:"..string.char(charcode)) + --debug(" curr:"..string.char(charcode)) buffer:blitFrom(glyph.bb, x + pen_x + glyph.l, y - glyph.t, 0, 0, glyph.bb:getWidth(), glyph.bb:getHeight()) end pen_x = pen_x + glyph.ax diff --git a/selectmenu.lua b/selectmenu.lua index da6f609bd..51a49efcf 100644 --- a/selectmenu.lua +++ b/selectmenu.lua @@ -270,7 +270,7 @@ function SelectMenu:choose(ypos, height) end if self.item_shortcuts[c] ~= nil and string.len(self.item_shortcuts[c]) == 3 then - -- print "Del", "Sym and "Ent" + -- debug "Del", "Sym and "Ent" renderUtf8Text(fb.bb, 13, y, fface, self.item_shortcuts[c], true) else @@ -322,14 +322,14 @@ function SelectMenu:choose(ypos, height) ev.code = adjustKeyEvents(ev) if ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_PRESS then keydef = Keydef:new(ev.code, getKeyModifier()) - print("key pressed: "..tostring(keydef)) + debug("key pressed: "..tostring(keydef)) command = self.commands:getByKeydef(keydef) if command ~= nil then - print("command to execute: "..tostring(command)) + debug("command to execute: "..tostring(command)) ret_code = command.func(self, keydef) else - print("command not found: "..tostring(command)) + debug("command not found: "..tostring(command)) end if ret_code == "break" then @@ -337,7 +337,7 @@ function SelectMenu:choose(ypos, height) end if self.selected_item ~= nil then - print("# selected "..self.selected_item) + debug("# selected "..self.selected_item) return self.selected_item, self.item_array[self.selected_item] end end -- EOF if diff --git a/unireader.lua b/unireader.lua index 53305e873..5985c2be6 100644 --- a/unireader.lua +++ b/unireader.lua @@ -1087,7 +1087,7 @@ function UniReader:drawOrCache(no, preCache) size = tile.w * tile.h / 2, bb = Blitbuffer.new(tile.w, tile.h) } - --print ("# new biltbuffer:"..dump(self.cache[pagehash])) + --debug ("# new biltbuffer:"..dump(self.cache[pagehash])) dc:setOffset(-tile.x, -tile.y) debug("rendering page", no) page:draw(dc, self.cache[pagehash].bb, 0, 0)