Compare commits
49 Commits
Author | SHA1 | Date |
---|---|---|
HW | 202b6fc039 | 12 years ago |
HW | 497e1d89de | 12 years ago |
HW | ab400b97ac | 12 years ago |
Dobrica Pavlinusic | ae9be768ab | 12 years ago |
NuPogodi | 944a3b5b05 | 12 years ago |
{Qingping,Dave} Hou | 78efdc77e3 | 12 years ago |
NuPogodi | 1831004da5 | 12 years ago |
NuPogodi | cccdf42892 | 12 years ago |
Dobrica Pavlinušić | b1486ee4bd | 12 years ago |
Qingping Hou | d2d8ad84ed | 12 years ago |
{Qingping,Dave} Hou | 763b97744b | 12 years ago |
Dobrica Pavlinusic | f55654f03e | 12 years ago |
Dobrica Pavlinusic | 9de055eb5d | 12 years ago |
Dobrica Pavlinusic | d678510d9a | 12 years ago |
Dobrica Pavlinusic | a08c35a52c | 12 years ago |
NuPogodi | 86513c3793 | 12 years ago |
NuPogodi | 3a76ec91fd | 12 years ago |
NuPogodi | f595d42431 | 12 years ago |
Qingping Hou | 6f5bf4a3b8 | 12 years ago |
{Qingping,Dave} Hou | c43a312725 | 12 years ago |
Dobrica Pavlinusic | 28161ae3d0 | 12 years ago |
NuPogodi | 93b5da0d8d | 12 years ago |
NuPogodi | 773a4d69b6 | 12 years ago |
NuPogodi | cd046a0637 | 12 years ago |
{Qingping,Dave} Hou | eaaff0d9bc | 12 years ago |
Dobrica Pavlinusic | 54657bb74c | 12 years ago |
Dobrica Pavlinusic | bca64dd4ef | 12 years ago |
Qingping Hou | 121f154313 | 12 years ago |
Dobrica Pavlinusic | ba19ab7029 | 12 years ago |
Dobrica Pavlinušić | e73803603b | 12 years ago |
Qingping Hou | c2cb95f8e8 | 12 years ago |
Qingping Hou | 84eb0e338f | 12 years ago |
Dobrica Pavlinušić | 7e885198ec | 12 years ago |
Qingping Hou | a73d9a5a52 | 12 years ago |
Qingping Hou | a672cf4ee0 | 12 years ago |
Dobrica Pavlinušić | 89f9a8c711 | 12 years ago |
Qingping Hou | d21ea032e5 | 12 years ago |
Qingping Hou | c275862ffe | 12 years ago |
Dobrica Pavlinušić | 0d4d7e7fb9 | 12 years ago |
Qingping Hou | c818d7e90e | 12 years ago |
Qingping Hou | 381b34cc04 | 12 years ago |
Qingping Hou | eb1fbebc5b | 12 years ago |
Qingping Hou | 1e36018021 | 12 years ago |
{Qingping,Dave} Hou | dad5b32331 | 12 years ago |
Dobrica Pavlinusic | 55cdb26823 | 12 years ago |
Dobrica Pavlinusic | de12c6aac0 | 12 years ago |
{Qingping,Dave} Hou | 246619b9c4 | 12 years ago |
Dobrica Pavlinusic | 90b8860ed5 | 12 years ago |
Dobrica Pavlinusic | 31108d536c | 12 years ago |
@ -0,0 +1,24 @@
|
||||
-- List of acceptable extentions
|
||||
|
||||
ext = {
|
||||
djvuRead = ";djvu;",
|
||||
pdfRead = ";pdf;xps;cbz;",
|
||||
creRead = ";epub;txt;rtf;htm;html;mobi;prc;azw;fb2;chm;pdb;doc;tcr;zip;"
|
||||
-- seems to accept pdb-files for PalmDoc only
|
||||
}
|
||||
|
||||
function ext:getReader(ftype)
|
||||
local s = ";"
|
||||
if ftype == "" then
|
||||
return nil
|
||||
elseif string.find(self.djvuRead,s..ftype..s) then
|
||||
return DJVUReader
|
||||
elseif string.find(self.pdfRead,s..ftype..s) then
|
||||
return PDFReader
|
||||
elseif string.find(self.creRead,s..ftype..s) then
|
||||
return CREReader
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,388 @@
|
||||
require "rendertext"
|
||||
require "keys"
|
||||
require "graphics"
|
||||
require "font"
|
||||
require "inputbox"
|
||||
require "dialog"
|
||||
require "filesearcher"
|
||||
require "settings"
|
||||
|
||||
FileHistory = {
|
||||
-- title height
|
||||
title_H = 40,
|
||||
-- spacing between lines
|
||||
spacing = 36,
|
||||
-- foot height
|
||||
foot_H = 28,
|
||||
-- horisontal margin
|
||||
margin_H = 10,
|
||||
|
||||
-- state buffer
|
||||
history_files = {},
|
||||
files = {},
|
||||
result = {},
|
||||
items = 0,
|
||||
page = 0,
|
||||
current = 1,
|
||||
oldcurrent = 1,
|
||||
}
|
||||
|
||||
function FileHistory:init(history_path)
|
||||
if history_path then
|
||||
self:setPath(history_path)
|
||||
else
|
||||
self:setPath("./history")
|
||||
end
|
||||
self:addAllCommands()
|
||||
end
|
||||
|
||||
function FileHistory:setPath(newPath)
|
||||
self.path = newPath
|
||||
self:readDir("-c ")
|
||||
self.items = #self.files
|
||||
if self.items == 0 then
|
||||
return nil
|
||||
end
|
||||
self.page = 1
|
||||
self.current = 1
|
||||
return true
|
||||
end
|
||||
|
||||
function FileHistory:readDir(order_criteria)
|
||||
self.history_files = {}
|
||||
self.files = {}
|
||||
local listfile = self.path.."/.history.txt"
|
||||
os.execute("ls "..order_criteria.."-1 "..self.path.." > "..listfile)
|
||||
for f in io.lines(listfile) do
|
||||
-- insert history files
|
||||
file_entry = {dir=self.path, name=f}
|
||||
table.insert(self.history_files, file_entry)
|
||||
-- and corresponding path & file items
|
||||
file_entry = {dir=HistoryToPath(f), name=HistoryToName(f)}
|
||||
table.insert(self.files, file_entry)
|
||||
end
|
||||
end
|
||||
|
||||
function FileHistory:setSearchResult(keywords)
|
||||
self.result = {}
|
||||
if keywords == "" or keywords == " " then
|
||||
-- show all history
|
||||
self.result = self.files
|
||||
else
|
||||
-- select history files with keywords in the filename
|
||||
for __,f in pairs(self.files) do
|
||||
if string.find(string.lower(f.name), keywords) then
|
||||
table.insert(self.result,f)
|
||||
end
|
||||
end
|
||||
end
|
||||
self.keywords = keywords
|
||||
self.items = #self.result
|
||||
self.page = 1
|
||||
self.current = 1
|
||||
end
|
||||
|
||||
function FileHistory:prevItem()
|
||||
if self.current == 1 then
|
||||
if self.page > 1 then
|
||||
self.current = self.perpage
|
||||
self.page = self.page - 1
|
||||
self.pagedirty = true
|
||||
end
|
||||
else
|
||||
self.current = self.current - 1
|
||||
self.markerdirty = true
|
||||
end
|
||||
end
|
||||
|
||||
function FileHistory:nextItem()
|
||||
if self.current == self.perpage then
|
||||
if self.page < (self.items / self.perpage) then
|
||||
self.current = 1
|
||||
self.page = self.page + 1
|
||||
self.pagedirty = true
|
||||
end
|
||||
else
|
||||
if self.page ~= math.floor(self.items / self.perpage) + 1
|
||||
or self.current + (self.page-1)*self.perpage < self.items then
|
||||
self.current = self.current + 1
|
||||
self.markerdirty = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function FileHistory:addAllCommands()
|
||||
self.commands = Commands:new{}
|
||||
-- search among last documents
|
||||
self.commands:add(KEY_S, nil, "S",
|
||||
"search among files",
|
||||
function(self)
|
||||
old_keywords = self.keywords
|
||||
self.keywords = InputBox:input(G_height - 100, 100,
|
||||
"Search:", old_keywords)
|
||||
if self.keywords then
|
||||
self:setSearchResult(self.keywords)
|
||||
else
|
||||
self.keywords = old_keywords
|
||||
end
|
||||
self.pagedirty = true
|
||||
end
|
||||
)
|
||||
-- last documents
|
||||
self.commands:add(KEY_L, nil, "L",
|
||||
"last documents",
|
||||
function(self)
|
||||
self:setSearchResult("")
|
||||
self.pagedirty = true
|
||||
end
|
||||
)
|
||||
-- show help page
|
||||
self.commands:add(KEY_H, nil, "H",
|
||||
"show help page",
|
||||
function(self)
|
||||
HelpPage:show(0, G_height, self.commands)
|
||||
self.pagedirty = true
|
||||
end
|
||||
)
|
||||
-- make screenshot
|
||||
self.commands:add(KEY_P, MOD_SHIFT, "P",
|
||||
"make screenshot",
|
||||
function(self)
|
||||
Screen:screenshot()
|
||||
end
|
||||
)
|
||||
|
||||
-- file info
|
||||
self.commands:add({KEY_FW_RIGHT, KEY_I}, nil, "joypad right",
|
||||
"document details",
|
||||
function(self)
|
||||
file_entry = self.result[self.perpage*(self.page-1)+self.current]
|
||||
FileInfo:show(file_entry.dir,file_entry.name)
|
||||
self.pagedirty = true
|
||||
end
|
||||
)
|
||||
|
||||
self.commands:add(KEY_FW_UP, nil, "joypad up",
|
||||
"goto previous item",
|
||||
function(self)
|
||||
self:prevItem()
|
||||
end
|
||||
)
|
||||
self.commands:add(KEY_FW_DOWN, nil, "joypad down",
|
||||
"goto next item",
|
||||
function(self)
|
||||
self:nextItem()
|
||||
end
|
||||
)
|
||||
self.commands:add({KEY_PGFWD, KEY_LPGFWD}, nil, ">",
|
||||
"next page",
|
||||
function(self)
|
||||
if self.page < (self.items / self.perpage) then
|
||||
if self.current + self.page*self.perpage > self.items then
|
||||
self.current = self.items - self.page*self.perpage
|
||||
end
|
||||
self.page = self.page + 1
|
||||
self.pagedirty = true
|
||||
else
|
||||
self.current = self.items - (self.page-1)*self.perpage
|
||||
self.markerdirty = true
|
||||
end
|
||||
end
|
||||
)
|
||||
self.commands:add({KEY_PGBCK, KEY_LPGBCK}, nil, "<",
|
||||
"previous page",
|
||||
function(self)
|
||||
if self.page > 1 then
|
||||
self.page = self.page - 1
|
||||
self.pagedirty = true
|
||||
else
|
||||
self.current = 1
|
||||
self.markerdirty = true
|
||||
end
|
||||
end
|
||||
)
|
||||
self.commands:add({KEY_F, KEY_AA}, nil, "F",
|
||||
"font menu",
|
||||
function(self)
|
||||
-- NuPogodi, 18.05.12: define the number of the current font in face_list
|
||||
local item_no = 0
|
||||
local face_list = Font:getFontList()
|
||||
while face_list[item_no] ~= Font.fontmap.cfont and item_no < #face_list do
|
||||
item_no = item_no + 1
|
||||
end
|
||||
|
||||
local fonts_menu = SelectMenu:new{
|
||||
menu_title = "Fonts Menu",
|
||||
item_array = face_list,
|
||||
-- NuPogodi, 18.05.12: define selected item
|
||||
current_entry = item_no - 1,
|
||||
}
|
||||
local re, font = fonts_menu:choose(0, G_height)
|
||||
if re then
|
||||
Font.fontmap["cfont"] = font
|
||||
Font:update()
|
||||
end
|
||||
self.pagedirty = true
|
||||
end
|
||||
)
|
||||
|
||||
self.commands:add({KEY_ENTER, KEY_FW_PRESS}, nil, "Enter",
|
||||
"open selected item",
|
||||
function(self)
|
||||
file_entry = self.result[self.perpage*(self.page-1)+self.current]
|
||||
file_full_path = file_entry.dir .. "/" .. file_entry.name
|
||||
|
||||
openFile(file_full_path)
|
||||
--reset height and item index if screen has been rotated
|
||||
local item_no = self.perpage * (self.page - 1) + self.current
|
||||
self.perpage = math.floor(G_height / self.spacing) - 2
|
||||
self.current = item_no % self.perpage
|
||||
self.page = math.floor(item_no / self.perpage) + 1
|
||||
|
||||
self.pagedirty = true
|
||||
end
|
||||
)
|
||||
self.commands:add({KEY_BACK, KEY_HOME}, nil, "Back",
|
||||
"back",
|
||||
function(self)
|
||||
return "break"
|
||||
end
|
||||
)
|
||||
self.commands:add({KEY_DEL}, nil, "Del",
|
||||
"delete document",
|
||||
function(self)
|
||||
file_entry = self.result[self.perpage*(self.page-1)+self.current]
|
||||
local file_to_del = file_entry.dir .. "/" .. file_entry.name
|
||||
InfoMessage:show("Press \'Y\' to confirm deleting... ",0)
|
||||
while true do
|
||||
ev = input.saveWaitForEvent()
|
||||
ev.code = adjustKeyEvents(ev)
|
||||
if ev.type == EV_KEY and ev.value ~= EVENT_VALUE_KEY_RELEASE then
|
||||
if ev.code == KEY_Y then
|
||||
-- delete the file itself
|
||||
os.execute("rm \""..file_to_del.."\"")
|
||||
-- and its history file, if any
|
||||
os.execute("rm \""..DocToHistory(file_to_del).."\"")
|
||||
-- to avoid showing just deleted file
|
||||
self:init()
|
||||
self:setSearchResult(self.keywords)
|
||||
end
|
||||
self.pagedirty = true
|
||||
break
|
||||
end -- if ev.type == EV_KEY
|
||||
end -- while
|
||||
end
|
||||
)
|
||||
self.commands:add({KEY_SPACE}, nil, "Space",
|
||||
"refresh page manually",
|
||||
function(self)
|
||||
self.pagedirty = true
|
||||
end
|
||||
)
|
||||
--[[ self.commands:add({KEY_B}, nil, "B",
|
||||
"file browser",
|
||||
function(self)
|
||||
--FileChooser:setPath(".")
|
||||
FileChooser:choose(0, G_height)
|
||||
self.pagedirty = true
|
||||
end
|
||||
)]]
|
||||
end
|
||||
|
||||
function FileHistory:choose(keywords)
|
||||
self.perpage = math.floor(G_height / self.spacing) - 2
|
||||
self.pagedirty = true
|
||||
self.markerdirty = false
|
||||
|
||||
self:setSearchResult(keywords)
|
||||
|
||||
while true do
|
||||
local cface = Font:getFace("cfont", 22)
|
||||
local tface = Font:getFace("tfont", 25)
|
||||
local fface = Font:getFace("ffont", 16)
|
||||
|
||||
if self.pagedirty then
|
||||
self.markerdirty = true
|
||||
fb.bb:paintRect(0, 0, G_width, G_height, 0)
|
||||
|
||||
-- draw header
|
||||
local header = "Last Documents"
|
||||
if self.keywords ~= "" and self.keywords ~= " " then
|
||||
--header = header .. " (filter: \'" .. string.upper(self.keywords) .. "\')"
|
||||
header = "Search Results for \'"..string.upper(self.keywords).."\'"
|
||||
end
|
||||
DrawTitle(header,self.margin_H,0,self.title_H,4,tface)
|
||||
|
||||
-- draw found results
|
||||
local c
|
||||
if self.items == 0 then -- nothing found
|
||||
y = self.title_H + self.spacing * 2
|
||||
renderUtf8Text(fb.bb, self.margin_H, y, cface,
|
||||
"Sorry, no files found.", true)
|
||||
self.markerdirty = false
|
||||
else -- found something, draw it
|
||||
for c = 1, self.perpage do
|
||||
local i = (self.page - 1) * self.perpage + c
|
||||
if i <= self.items then
|
||||
y = self.title_H + (self.spacing * c) + 4
|
||||
local ftype = string.lower(string.match(self.result[i].name, ".+%.([^.]+)") or "")
|
||||
DrawFileItem(self.result[i].name,self.margin_H,y,ftype)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- draw footer
|
||||
all_page = math.ceil(self.items/self.perpage)
|
||||
DrawFooter("Page "..self.page.." of "..all_page,fface,self.foot_H)
|
||||
|
||||
end
|
||||
|
||||
if self.markerdirty then
|
||||
if not self.pagedirty then
|
||||
if self.oldcurrent > 0 then
|
||||
y = self.title_H + (self.spacing * self.oldcurrent) + 12
|
||||
fb.bb:paintRect(self.margin_H, y, G_width - 2 * self.margin_H, 3, 0)
|
||||
fb:refresh(1, self.margin_H, y, G_width - 2 * self.margin_H, 3)
|
||||
end
|
||||
end
|
||||
-- draw new marker line
|
||||
y = self.title_H + (self.spacing * self.current) + 12
|
||||
fb.bb:paintRect(self.margin_H, y, G_width - 2 * self.margin_H, 3, 15)
|
||||
if not self.pagedirty then
|
||||
fb:refresh(1, self.margin_H, y, G_width - 2 * self.margin_H, 3)
|
||||
end
|
||||
self.oldcurrent = self.current
|
||||
self.markerdirty = false
|
||||
end
|
||||
|
||||
if self.pagedirty then
|
||||
fb:refresh(0)
|
||||
self.pagedirty = false
|
||||
end
|
||||
|
||||
local ev = input.saveWaitForEvent()
|
||||
ev.code = adjustKeyEvents(ev)
|
||||
if ev.type == EV_KEY and ev.value ~= EVENT_VALUE_KEY_RELEASE then
|
||||
keydef = Keydef:new(ev.code, getKeyModifier())
|
||||
debug("key pressed: "..tostring(keydef))
|
||||
|
||||
command = self.commands:getByKeydef(keydef)
|
||||
if command ~= nil then
|
||||
debug("command to execute: "..tostring(command))
|
||||
ret_code = command.func(self, keydef)
|
||||
else
|
||||
debug("command not found: "..tostring(command))
|
||||
end
|
||||
|
||||
if ret_code == "break" then
|
||||
break
|
||||
end
|
||||
|
||||
if self.selected_item ~= nil then
|
||||
debug("# selected "..self.selected_item)
|
||||
return self.selected_item
|
||||
end
|
||||
end -- if
|
||||
end -- while true
|
||||
return nil
|
||||
end
|
@ -0,0 +1,281 @@
|
||||
require "rendertext"
|
||||
require "keys"
|
||||
require "graphics"
|
||||
require "font"
|
||||
require "inputbox"
|
||||
require "dialog"
|
||||
require "settings"
|
||||
--require "extentions"
|
||||
|
||||
FileInfo = {
|
||||
-- title height
|
||||
title_H = 40,
|
||||
-- spacing between lines
|
||||
spacing = 36,
|
||||
-- foot height
|
||||
foot_H = 28,
|
||||
-- horisontal margin
|
||||
margin_H = 10,
|
||||
-- state buffer
|
||||
result = {},
|
||||
files = {},
|
||||
lcolumn_width = 0,
|
||||
items = 0,
|
||||
page = 1,
|
||||
current = 1,
|
||||
pathfile = "",
|
||||
}
|
||||
|
||||
function FileInfo:FileCreated(fname,attr)
|
||||
return os.date("%d %b %Y, %H:%M:%S", lfs.attributes(fname,attr))
|
||||
end
|
||||
-- NuPogodi, 26.05.12: a bit changed to return string from size
|
||||
function FileInfo:FileSize(size)
|
||||
if size < 1024 then
|
||||
return size.." Bytes"
|
||||
elseif size < 2^20 then
|
||||
return string.format("%.2f", size/2^10).."KB \("..size.." Bytes\)"
|
||||
else
|
||||
return string.format("%.2f", size/2^20).."MB \("..size.." Bytes\)"
|
||||
end
|
||||
end -- end of changes (NuPogodi, 26.05.12)
|
||||
|
||||
function FileInfo:init(path,fname)
|
||||
self.pathfile = path.."/"..fname
|
||||
self.result = {}
|
||||
self:addAllCommands()
|
||||
|
||||
local info_entry = {dir = "Name", name = fname}
|
||||
table.insert(self.result, info_entry)
|
||||
info_entry = {dir = "Path", name = path}
|
||||
table.insert(self.result, info_entry)
|
||||
-- NuPogodi, 26.05.12: now one has to call FileInfo:FileSize(integer)
|
||||
info_entry = {dir = "Size", name = FileInfo:FileSize(lfs.attributes(self.pathfile,"size"))}
|
||||
table.insert(self.result, info_entry)
|
||||
-- NuPogodi, 26.05.12: size & filename of unzipped entry for zips
|
||||
if string.lower(string.match(fname, ".+%.([^.]+)")) == "zip" then
|
||||
local outfile = "./data/zip_content"
|
||||
local l, s = 1, ""
|
||||
os.execute("unzip ".."-l \""..self.pathfile.."\" > "..outfile)
|
||||
if io.open(outfile, "r") then
|
||||
for lines in io.lines(outfile) do
|
||||
if l == 4 then s = lines break else l = l + 1 end
|
||||
end
|
||||
-- due to rewriting FileInfo:FileSize(integer), one can use it now
|
||||
info_entry = { dir = "Unpacked", name = FileInfo:FileSize(tonumber(string.sub(s,1,11))) }
|
||||
table.insert(self.result, info_entry)
|
||||
--[[ TODO: When the fileentry inside zips is encoded as ANSI (codes 128-255)
|
||||
any attempt to print such fileentry causes crash by drawing!!! When fileentries
|
||||
are encoded as UTF8, everything seems fine
|
||||
info_entry = { dir = "Content", name = string.sub(s,29,-1) }
|
||||
table.insert(self.result, info_entry) ]]
|
||||
end
|
||||
end -- end of changes (NuPogodi, 26.05.12)
|
||||
|
||||
info_entry = {dir = "Created", name = FileInfo:FileCreated(self.pathfile,"change")}
|
||||
table.insert(self.result, info_entry)
|
||||
info_entry = {dir = "Modified", name = FileInfo:FileCreated(self.pathfile,"modification")}
|
||||
table.insert(self.result, info_entry)
|
||||
|
||||
-- if the document was already opened
|
||||
local history = DocToHistory(self.pathfile)
|
||||
local file, msg = io.open(history,"r")
|
||||
if not file then
|
||||
info_entry = {dir = "Last Read", name = "Never"}
|
||||
table.insert(self.result, info_entry)
|
||||
else
|
||||
info_entry = {dir = "Last Read", name = FileInfo:FileCreated(history,"change")}
|
||||
table.insert(self.result, info_entry)
|
||||
local file_type = string.lower(string.match(self.pathfile, ".+%.([^.]+)"))
|
||||
local to_search, add, factor = "\[\"last_percent\"\]", "\%", 100
|
||||
if ext:getReader(file_type) ~= CREReader then
|
||||
to_search = "\[\"last_page\"\]"
|
||||
add = " pages"
|
||||
factor = 1
|
||||
end
|
||||
for line in io.lines(history) do
|
||||
if string.match(line,"%b[]") == to_search then
|
||||
local cdc = tonumber(string.match(line, "%d+")) / factor
|
||||
info_entry = {dir = "Completed", name = string.format("%d",cdc)..add }
|
||||
table.insert(self.result, info_entry)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
self.items = #self.result
|
||||
-- now calculating the horizontal space for left column
|
||||
local tw, width
|
||||
for i = 1, self.items do
|
||||
tw = TextWidget:new({text = self.result[i].dir, face = Font:getFace("tfont", 22)})
|
||||
width = tw:getSize().w
|
||||
if width > self.lcolumn_width then self.lcolumn_width = width end
|
||||
tw:free()
|
||||
end
|
||||
end
|
||||
|
||||
function FileInfo:show(path,name)
|
||||
-- at first, one has to test whether the file still exists or not
|
||||
-- it's necessary for last documents
|
||||
if not io.open(path.."/"..name,"r") then return nil end
|
||||
-- then goto main functions
|
||||
self.perpage = math.floor(G_height / self.spacing) - 2
|
||||
self.pagedirty = true
|
||||
self.markerdirty = false
|
||||
FileInfo:init(path,name)
|
||||
|
||||
while true do
|
||||
local cface = Font:getFace("cfont", 22)
|
||||
local lface = Font:getFace("tfont", 22)
|
||||
local tface = Font:getFace("tfont", 25)
|
||||
local fface = Font:getFace("ffont", 16)
|
||||
|
||||
if self.pagedirty then
|
||||
self.markerdirty = true
|
||||
-- gap between title rectangle left & left text drawing point
|
||||
fb.bb:paintRect(0, 0, G_width, G_height, 0)
|
||||
-- draw menu title
|
||||
DrawTitle("Document Information",self.margin_H,0,self.title_H,4,tface)
|
||||
-- position of left column
|
||||
local x1 = self.margin_H
|
||||
-- position of right column + its width + a small gap between columns
|
||||
local x2 = x1 + self.lcolumn_width + 15
|
||||
-- y-position correction because of the multiline drawing
|
||||
local dy, c = 5, 1
|
||||
for c = 1, self.perpage do
|
||||
local i = (self.page - 1) * self.perpage + c
|
||||
if i <= self.items then
|
||||
y = self.title_H + self.spacing * c + dy
|
||||
renderUtf8Text(fb.bb, x1, y, lface, self.result[i].dir, true)
|
||||
dy = dy + renderUtf8Multiline(fb.bb, x2, y, cface, self.result[i].name, true,
|
||||
G_width - self.margin_H - x2, 1.65).y - y
|
||||
end
|
||||
end
|
||||
-- draw footer
|
||||
all_page = math.ceil(self.items/self.perpage)
|
||||
DrawFooter("Page "..self.page.." of "..all_page,fface,self.foot_H)
|
||||
end
|
||||
|
||||
if self.pagedirty then
|
||||
fb:refresh(0)
|
||||
self.pagedirty = false
|
||||
end
|
||||
|
||||
local ev = input.saveWaitForEvent()
|
||||
ev.code = adjustKeyEvents(ev)
|
||||
if ev.type == EV_KEY and ev.value ~= EVENT_VALUE_KEY_RELEASE then
|
||||
keydef = Keydef:new(ev.code, getKeyModifier())
|
||||
debug("key pressed: "..tostring(keydef))
|
||||
|
||||
command = self.commands:getByKeydef(keydef)
|
||||
if command ~= nil then
|
||||
debug("command to execute: "..tostring(command))
|
||||
ret_code = command.func(self, keydef)
|
||||
else
|
||||
debug("command not found: "..tostring(command))
|
||||
end
|
||||
|
||||
if ret_code == "break" then break end
|
||||
|
||||
if self.selected_item ~= nil then
|
||||
debug("# selected "..self.selected_item)
|
||||
return self.selected_item
|
||||
end
|
||||
end -- if
|
||||
end -- while true
|
||||
return nil
|
||||
end
|
||||
|
||||
function FileInfo:addAllCommands()
|
||||
self.commands = Commands:new{}
|
||||
|
||||
self.commands:add({KEY_SPACE}, nil, "Space",
|
||||
"refresh page manually",
|
||||
function(self)
|
||||
self.pagedirty = true
|
||||
end
|
||||
)
|
||||
self.commands:add(KEY_H,nil,"H",
|
||||
"show help page",
|
||||
function(self)
|
||||
HelpPage:show(0, G_height, self.commands)
|
||||
self.pagedirty = true
|
||||
end
|
||||
)
|
||||
self.commands:add(KEY_L, nil, "L",
|
||||
"last documents",
|
||||
function(self)
|
||||
FileHistory:init()
|
||||
FileHistory:choose("")
|
||||
self.pagedirty = true
|
||||
end
|
||||
)
|
||||
self.commands:add({KEY_F, KEY_AA}, nil, "F",
|
||||
"font menu",
|
||||
function(self)
|
||||
local item_no = 0
|
||||
local face_list = Font:getFontList()
|
||||
while face_list[item_no] ~= Font.fontmap.cfont and item_no < #face_list do
|
||||
item_no = item_no + 1
|
||||
end
|
||||
|
||||
local fonts_menu = SelectMenu:new{
|
||||
menu_title = "Fonts Menu",
|
||||
item_array = face_list,
|
||||
current_entry = item_no - 1,
|
||||
}
|
||||
local re, font = fonts_menu:choose(0, G_height)
|
||||
if re then
|
||||
Font.fontmap["cfont"] = font
|
||||
Font:update()
|
||||
end
|
||||
self.pagedirty = true
|
||||
end
|
||||
)
|
||||
self.commands:add({KEY_PGFWD, KEY_LPGFWD}, nil, ">",
|
||||
"next page",
|
||||
function(self)
|
||||
if self.page < (self.items / self.perpage) then
|
||||
if self.current + self.page*self.perpage > self.items then
|
||||
self.current = self.items - self.page*self.perpage
|
||||
end
|
||||
self.page = self.page + 1
|
||||
self.pagedirty = true
|
||||
else
|
||||
self.current = self.items - (self.page-1)*self.perpage
|
||||
self.markerdirty = true
|
||||
end
|
||||
end
|
||||
)
|
||||
self.commands:add({KEY_PGBCK, KEY_LPGBCK}, nil, "<",
|
||||
"previous page",
|
||||
function(self)
|
||||
if self.page > 1 then
|
||||
self.page = self.page - 1
|
||||
self.pagedirty = true
|
||||
else
|
||||
self.current = 1
|
||||
self.markerdirty = true
|
||||
end
|
||||
end
|
||||
)
|
||||
self.commands:add({KEY_ENTER, KEY_FW_PRESS}, nil, "Enter",
|
||||
"open document",
|
||||
function(self)
|
||||
openFile(self.pathfile)
|
||||
self.pagedirty = true
|
||||
end
|
||||
)
|
||||
-- make screenshot
|
||||
self.commands:add(KEY_P, MOD_SHIFT, "P",
|
||||
"make screenshot",
|
||||
function(self)
|
||||
Screen:screenshot()
|
||||
end
|
||||
)
|
||||
self.commands:add({KEY_BACK, KEY_FW_LEFT}, nil, "Back",
|
||||
"back",
|
||||
function(self)
|
||||
return "break"
|
||||
end
|
||||
)
|
||||
end
|
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
/mnt/us/launchpad/kpdf.sh
|
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
/mnt/us/launchpad/kpdf.sh /mnt/us/documents
|
@ -0,0 +1,74 @@
|
||||
body { text-align: left; text-indent: 0px }
|
||||
p { text-align: justify; text-indent: 2em; margin-top:0em; margin-bottom: 0em }
|
||||
|
||||
empty-line { height: 1em }
|
||||
|
||||
hr { height: 1px; /* background-color: #808080; */ margin-top: 0.5em; margin-bottom: 0.5em }
|
||||
|
||||
sub { vertical-align: sub; font-size: 70% }
|
||||
sup { vertical-align: super; font-size: 70% }
|
||||
strong, b { font-weight: bold }
|
||||
emphasis, i { font-style: italic }
|
||||
|
||||
a { text-decoration: underline }
|
||||
a[type="note"] { vertical-align: super; font-size: 70%; text-decoration: none }
|
||||
|
||||
image { text-align: center; text-indent: 0px }
|
||||
p image { display: inline }
|
||||
|
||||
title p, subtitle p, h1 p, h2 p, h3 p, h4 p, h5 p, h6 p { text-align: center; text-indent: 0px }
|
||||
cite p, epigraph p { text-align: left; text-indent: 0px }
|
||||
v { text-align: left; text-indent: 0px }
|
||||
|
||||
stanza + stanza { margin-top: 1em; }
|
||||
stanza { margin-left: 30%; text-align: left; font-style: italic }
|
||||
poem { margin-top: 1em; margin-bottom: 1em; text-indent: 0px }
|
||||
text-author { font-weight: bold; font-style: italic; margin-left: 5%}
|
||||
epigraph { margin-left: 25%; margin-right: 1em; text-align: left; text-indent:
|
||||
1px; font-style: italic; margin-top: 15px; margin-bottom: 25px }
|
||||
cite { font-style: italic; margin-left: 5%; margin-right: 5%; text-align: justify;
|
||||
margin-top: 20px; margin-bottom: 20px }
|
||||
|
||||
title, h1, h2 { text-align: center; text-indent: 0px; font-weight: bold; hyphenate: none;
|
||||
page-break-before: always; page-break-inside: avoid; page-break-after: avoid; }
|
||||
subtitle, h3, h4, h5, h6 { text-align: center; text-indent: 0px; font-weight: bold;
|
||||
hyphenate: none; page-break-inside: avoid; page-break-after: avoid; }
|
||||
title { font-size: 110%; margin-top: 0.7em; margin-bottom: 0.5em }
|
||||
subtitle { font-style: italic; margin-top: 0.3em; margin-bottom: 0.3em }
|
||||
h1 { font-size: 150% }
|
||||
h2 { font-size: 140% }
|
||||
h3 { font-size: 130% }
|
||||
h4 { font-size: 120% }
|
||||
h5 { font-size: 110% }
|
||||
|
||||
|
||||
table { font-size: 80% }
|
||||
td, th { text-indent: 0px; padding: 3px }
|
||||
th { font-weight: bold; /* background-color: #DDD */ }
|
||||
table > caption { text-indent: 0px; padding: 4px; /* background-color: #EEE */ }
|
||||
|
||||
code, pre { display: block; white-space: pre; text-align: left;
|
||||
font-family: "Droid Sans Mono", monospace; text-align: left }
|
||||
|
||||
body[name="notes"] { font-size: 70%; }
|
||||
body[name="notes"] section title { display: run-in; text-align: left; font-size: 110%;
|
||||
font-weight: bold; page-break-before: auto; page-break-inside: auto;
|
||||
page-break-after: auto; }
|
||||
body[name="notes"] section title p { display: inline }
|
||||
|
||||
description { display: block; }
|
||||
title-info { display: block; }
|
||||
annotation { margin-left: 5%; margin-right: 5%; font-size: 80%; font-style: italic;
|
||||
text-align: justify; text-indent: 2em }
|
||||
date { display: block; font-size: 80%; font-style: italic; text-align: center }
|
||||
genre { display: none; }
|
||||
author { display: none; }
|
||||
book-title { display: none; }
|
||||
keywords { display: none; }
|
||||
lang { display: none; }
|
||||
src-lang { display: none; }
|
||||
translator { display: none; }
|
||||
document-info { display: none; }
|
||||
publish-info { display: none; }
|
||||
custom-info { display: none; }
|
||||
coverpage { display: none }
|
@ -1 +1 @@
|
||||
Subproject commit 7a73d1666538fe9dd7d84d7e18135b03c21be2ca
|
||||
Subproject commit 99882134490b47ebb28107cebfbeb8eafb070f54
|
After Width: | Height: | Size: 259 B |
After Width: | Height: | Size: 288 B |
After Width: | Height: | Size: 321 B |
After Width: | Height: | Size: 237 B |
After Width: | Height: | Size: 249 B |
After Width: | Height: | Size: 191 B |
After Width: | Height: | Size: 326 B |
After Width: | Height: | Size: 311 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 538 B |
After Width: | Height: | Size: 268 B |
After Width: | Height: | Size: 276 B |
After Width: | Height: | Size: 269 B |
After Width: | Height: | Size: 266 B |
After Width: | Height: | Size: 276 B |
After Width: | Height: | Size: 304 B |
After Width: | Height: | Size: 292 B |
After Width: | Height: | Size: 334 B |