Project info

Here’s something I threw together for fun. It allows you to list your projects and see what tabs are used in it. It shows the number of lines and bytes in each tab and also shows you the total tabs, lines, and bytes in a project. Select a slider to choose Documents, Craft, or Examples.

PS. Slide your finger up/down to scroll.

PSS. Added code to sort the projects and tabs within each project.


viewer.mode=STANDARD

function setup()
    fill(255)
    textMode(CORNER)
    parameter.boolean("Examples",false,showE)
    parameter.boolean("Craft",false,showC)
    parameter.boolean("Documents",true,showD)
end

function showD()
    Examples,Craft=false,false
    show("Documents")
end
    
function showE()
    Documents,Craft=false,false
    show("Examples")
end
            
function showC()
    Examples,Documents=false,false
    show("Craft")
end
    
function show(where) 
    pos=0
    list={}
    table.insert(list,where)
    table.insert(list,"  ")
    tab=listProjects(where)
    table.sort(tab)    
    for a,b in pairs(tab) do
        table.insert(list,b)
        tabs=listProjectTabs(where..":"..b)
        table.sort(tabs)
        tTabs=#tabs
        tLines,tBytes=0,0
        for c,d in pairs(tabs) do
            z=readProjectTab(where..":"..b..":"..d)
            tBytes=tBytes+#z
            cnt=1
            for w=1,#z do
                if string.sub(z,w,w)=="\
" then
                    cnt=cnt+1
                end
            end
            tLines=tLines+cnt
            table.insert(list,"       |-----"..d.."     Lines ("..cnt..")   Bytes ("..#z..")")
        end
        table.insert(list,"              Total tabs  ("..tTabs..")  Total lines  ("..tLines..")  Total bytes  ("..tBytes..")")
        table.insert(list,"  ")
    end
    
end

function draw()
    background(0)
    for a,b in pairs(list) do
        text(b,20,HEIGHT-a*20+pos)
    end    
end

function touched(t)
    if t.state==CHANGED then
        if t.deltaY>0 then
            pos=pos+10
        elseif t.deltaY<0 and pos>0 then
            pos=pos-10           
        end
    end    
end

nice