summaryrefslogtreecommitdiff
path: root/dalos-isoviewer.lua
diff options
context:
space:
mode:
Diffstat (limited to 'dalos-isoviewer.lua')
-rw-r--r--dalos-isoviewer.lua123
1 files changed, 68 insertions, 55 deletions
diff --git a/dalos-isoviewer.lua b/dalos-isoviewer.lua
index 71888da..e7f4b1e 100644
--- a/dalos-isoviewer.lua
+++ b/dalos-isoviewer.lua
@@ -30,10 +30,10 @@ dalosp.isoviewer = {
local index = 1
local currentDir = {}
local cdutil = self.cdutil
-
- List[1] = NULL
-
+ local FList = {}
local root = cdutil:findpath(arg_dir)
+
+ List.RemoveItem = nil
for name, dir in root:iterate(cdutil) do
if name ~= "." and name ~= ".." then
@@ -45,7 +45,7 @@ dalosp.isoviewer = {
Sector = dir.Sector,
TypeFile = "File Folder",
DateFile = string.format('%02d', dir.Day) .. "/" .. string.format('%02d', dir.Month) .. "/" .. dir.Year .. " " .. string.format('%02d', dir.Hour) .. ":" .. string.format('%02d', dir.Minute) .. ":" .. string.format('%02d', dir.Second),
- Parent = arg_dir
+ Parent = arg_dir,
}
else
elem = {
@@ -54,7 +54,7 @@ dalosp.isoviewer = {
Sector = dir.Sector,
TypeFile = "File",
DateFile = string.format('%02d', dir.Day) .. "/" .. string.format('%02d', dir.Month) .. "/" .. dir.Year .. " " .. string.format('%02d', dir.Hour) .. ":" .. string.format('%02d', dir.Minute) .. ":" .. string.format('%02d', dir.Second),
- Parent = arg_dir
+ Parent = arg_dir,
}
end
table.insert(currentDir, elem)
@@ -65,56 +65,59 @@ dalosp.isoviewer = {
for i, entry in ipairs(currentDir) do
List[i] = self:completeSpace(entry.Name, 20) .. " " .. self:completeSpace(entry.Size, 9, "right") .. " " .. self:completeSpace(entry.Sector, 6, "right") .. " " .. self:completeSpace(entry.TypeFile, 15) .. " " .. self:completeSpace(entry.DateFile, 19) .. " "
+ FList[i] = { full = entry.Parent .. entry.Name, type = entry.TypeFile }
end
+
+ List.FList = FList
end,
fillListComplete = function (self, List, ISOElements)
+ local FList = {}
+
+ List.RemoveItem = nil
+
for i, entry in ipairs(ISOElements) do
List[i] = self:completeSpace(entry.Name, 20) .. " " .. self:completeSpace(entry.Sector, 6, "right") .. " " .. self:completeSpace(entry.Size, 9, "right") .. " " .. self:completeSpace(math.ceil(entry.Size / 2048), 9, "right") .. " " .. self:completeSpace(entry.TypeFile, 15)
+ FList[i] = { full = entry.Parent .. entry.Name, type = entry.TypeFile }
end
+
+ List.FList = FList
end,
getISOElements = function (self)
- local tree = {}
local ISOElements = {}
local cdutil = self.cdutil
- local function list_tree(arg_root, arg_tree)
+ local function list_tree(arg_root)
local root = cdutil:findpath(arg_root)
+ local tree = {}
for name, dir in root:iterate(cdutil) do
if name ~= "." and name ~= ".." then
+ local elem = {
+ Name = name,
+ Size = dir.Size,
+ Sector = dir.Sector,
+ DateFile = string.format('%02d', dir.Day) .. "/" .. string.format('%02d', dir.Month) .. "/" .. dir.Year .. " " .. string.format('%02d', dir.Hour) .. ":" .. string.format('%02d', dir.Minute) .. ":" .. string.format('%02d', dir.Second),
+ Parent = arg_root,
+ }
if dir:isdir() then
- local elem1 = { branchname = name }
-
- local elem2 = {
- Name = name,
- Size = dir.Size,
- Sector = dir.Sector,
- TypeFile = "File Folder",
- DateFile = string.format('%02d', dir.Day) .. "/" .. string.format('%02d', dir.Month) .. "/" .. dir.Year .. " " .. string.format('%02d', dir.Hour) .. ":" .. string.format('%02d', dir.Minute) .. ":" .. string.format('%02d', dir.Second),
- Parent = arg_root
- }
- table.insert(ISOElements, elem2)
-
- list_tree(arg_root .. name .. "/", elem1)
- table.insert(arg_tree, elem1)
+ elem.TypeFile = "File Folder"
+
+ local subtree = list_tree(arg_root .. name .. "/")
+ subtree.branchname = name
+ table.insert(tree, subtree)
else
- local elem2 = {
- Name = name,
- Size = dir.Size,
- Sector = dir.Sector,
- TypeFile = "File",
- DateFile = string.format('%02d', dir.Day) .. "/" .. string.format('%02d', dir.Month) .. "/" .. dir.Year .. " " .. string.format('%02d', dir.Hour) .. ":" .. string.format('%02d', dir.Minute) .. ":" .. string.format('%02d', dir.Second),
- Parent = arg_root
- }
- table.insert(ISOElements, elem2)
+ elem.TypeFile = "File"
end
+ table.insert(ISOElements, elem)
end
end
+
+ return tree
end
-
- list_tree("/", tree)
+
+ tree = list_tree "/"
table.sort(ISOElements, function(a, b) return a.Sector < b.Sector end)
@@ -127,6 +130,7 @@ dalosp.isoviewer = {
iup.TreeSetValue(self.controlTree, {})
self.controlList.RemoveItem = nil
self.controlListComplete.RemoveItem = nil
+ self:set_houtput(nil)
if h then
local cdutil = cdutils(h)
@@ -138,13 +142,26 @@ dalosp.isoviewer = {
local treeElements, ISOElements = self:getISOElements()
iup.TreeSetValue(self.controlTree, treeElements)
self.controlTree.name = volid
-
- self:fillList(self.controlList, "/")
+
+ self:fillList(self.controlList, "/")
self:fillListComplete(self.controlListComplete, ISOElements)
end
end,
create = function (d, tab, settings)
+ tab.ninputs = 1
+ tab.noutputs = 1
+ tab.otype = dalos.objtype.LUA_VIEWER
+ tab.activate = function (self) self.dlg:show() end
+ tab.configure = dalosp.isoviewer.configure
+ tab.input_change = dalosp.isoviewer.input_change
+ tab.default_name = "Isoviewer"
+ tab.ntype = "Isoviewer"
+ tab.get_settings = dalosp.isoviewer.get_settings
+ local extra = {}
+
+ local obj = dalos.object(d, tab, extra)
+
local function create_tree(volid)
local control_tree = iup.tree {
EXPAND = "VERTICAL",
@@ -186,11 +203,12 @@ dalosp.isoviewer = {
controlListComplete = create_list("100x270")
controlList.MULTIPLE = "YES"
- -- A REVOIR --
function controlList:dblclick_cb(pos, text)
+--[[
if currentDir[pos].TypeFile == "File Folder" then
- fillList(controlList, currentDir[pos].Parent .. currentDir[pos].Name .. "/")
+ obj:fillList(self.controlList, currentDir[pos].Parent .. currentDir[pos].Name .. "/")
end
+]]--
end
function controlTree:selection_cb(id, status)
@@ -210,19 +228,27 @@ dalosp.isoviewer = {
dir = dir .. parent[i]
end
- fillList(controlList, dir)
+ obj:fillList(controlList, dir)
return iup.DEFAULT
end
-
- function controlList:button_cb(but, pressed, x, y, status)
- if but == iup.BUTTON3 and pressed == 1 then
- --menuList:popup(iup.MOUSEPOS, iup.MOUSEPOS)
+
+ local listAction = function (self, text, pos, state)
+ if state ~= 1 then return iup.DEFAULT end
+ local file = self.FList[pos]
+ if file.type == "File" then
+ local cdutil = obj.cdutil
+ local dir = cdutil:findpath(file.full)
+ obj:set_houtput(cdutil:cdfile(dir))
+ else
+ obj:set_houtput(nil)
end
-
return iup.DEFAULT
end
+ controlList.action = listAction
+ controlListComplete.action = listAction
+
local dlg = iup.dialog {
TITLE = "Lua-ISOViewer",
MARGIN = "5x5",
@@ -260,19 +286,6 @@ dalosp.isoviewer = {
},
}
- tab.ninputs = 1
- tab.noutputs = 1
- tab.otype = dalos.objtype.LUA_VIEWER
- tab.activate = function (self) self.dlg:show() end
- tab.configure = dalosp.isoviewer.configure
- tab.input_change = dalosp.isoviewer.input_change
- tab.default_name = "Isoviewer"
- tab.ntype = "Isoviewer"
- tab.get_settings = dalosp.isoviewer.get_settings
- local extra = {}
-
- local obj = dalos.object(d, tab, extra)
-
obj.dlg = dlg
obj.completeSpace = dalosp.isoviewer.completeSpace