mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 19:25:20 -04:00
Update ls.lua
This commit is contained in:
parent
23be2a7ebd
commit
f269d19245
@ -28,7 +28,10 @@ for i = 1, #dirs do
|
|||||||
end
|
end
|
||||||
local lsd = {}
|
local lsd = {}
|
||||||
local lsf = {}
|
local lsf = {}
|
||||||
|
local m = 1
|
||||||
for f in list do
|
for f in list do
|
||||||
|
m = math.max(m,f:len())
|
||||||
|
|
||||||
if f:sub(-1) == "/" then
|
if f:sub(-1) == "/" then
|
||||||
if options.p then
|
if options.p then
|
||||||
table.insert(lsd, f)
|
table.insert(lsd, f)
|
||||||
@ -39,17 +42,29 @@ for i = 1, #dirs do
|
|||||||
table.insert(lsf, f)
|
table.insert(lsf, f)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
m = m + 2
|
||||||
table.sort(lsd)
|
table.sort(lsd)
|
||||||
table.sort(lsf)
|
table.sort(lsf)
|
||||||
setColor(0x66CCFF)
|
setColor(0x66CCFF)
|
||||||
|
|
||||||
|
local i = 1
|
||||||
|
local columns = math.floor (({component.invoke(component.list('gpu')(),'getResolution')})[1]/m)
|
||||||
|
local sWidth = ({component.invoke(component.list('gpu')(),'getResolution')})[1]
|
||||||
|
|
||||||
for _, d in ipairs(lsd) do
|
for _, d in ipairs(lsd) do
|
||||||
if options.a or d:sub(1, 1) ~= "." then
|
if options.a or d:sub(1, 1) ~= "." then
|
||||||
io.write(d .. "\t")
|
io.write(d .. string.rep (' ', m - d:len()))
|
||||||
if options.l or io.output() ~= io.stdout then
|
if options.l or io.output() ~= io.stdout then
|
||||||
io.write("\n")
|
io.write("\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if sWidth ~= m * columns and i % columns == 0 then
|
||||||
|
io.write ("\n")
|
||||||
|
end
|
||||||
|
i = i + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, f in ipairs(lsf) do
|
for _, f in ipairs(lsf) do
|
||||||
if fs.isLink(fs.concat(path, f)) then
|
if fs.isLink(fs.concat(path, f)) then
|
||||||
setColor(0xFFAA00)
|
setColor(0xFFAA00)
|
||||||
@ -59,7 +74,7 @@ for i = 1, #dirs do
|
|||||||
setColor(0xFFFFFF)
|
setColor(0xFFFFFF)
|
||||||
end
|
end
|
||||||
if options.a or f:sub(1, 1) ~= "." then
|
if options.a or f:sub(1, 1) ~= "." then
|
||||||
io.write(f .. "\t")
|
io.write(f .. string.rep (' ', m - f:len()) )
|
||||||
if options.l then
|
if options.l then
|
||||||
setColor(0xFFFFFF)
|
setColor(0xFFFFFF)
|
||||||
io.write(fs.size(fs.concat(path, f)), "\n")
|
io.write(fs.size(fs.concat(path, f)), "\n")
|
||||||
@ -67,7 +82,13 @@ for i = 1, #dirs do
|
|||||||
io.write("\n")
|
io.write("\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if sWidth ~= m * columns and i % columns == 0 then
|
||||||
|
io.write ("\n")
|
||||||
|
end
|
||||||
|
i = i + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
setColor(0xFFFFFF)
|
setColor(0xFFFFFF)
|
||||||
if options.M then
|
if options.M then
|
||||||
io.write("\n" .. tostring(#lsf) .. " File(s)")
|
io.write("\n" .. tostring(#lsf) .. " File(s)")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user