use debug to print debug info

pull/2/merge v2012.04
Qingping Hou 12 years ago
parent 35e4ceaf57
commit 3306346dba

@ -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

@ -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 <key>*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]

@ -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()

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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")

@ -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

@ -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

@ -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)

Loading…
Cancel
Save