I wrote this to help me write class code.
Hope you like it.
It also includes a function to create your own icon for the CODEA project home page.
-- ClassHelper
--BACKUP original
--[[
Use function INITSELFS(tabName,className,classFuncName,parameters) to generate
in tab tabName
function className:classFuncName(x)
self.x=x or 0 -- comments
end
from the long string
parm name : what goes after
x: or 0 -- comments
in
end
]]
displayMode(FULLSCREEN)
function setup()
saveProjectInfo("Description","Class CODEA Generation for CODEA Enlightenment")
saveProjectInfo("Author","CODING ON NAPKINS")
setProjectIcon("GENERATE self.x=x"
.."\
class code helper\
"
..os.date()
.."\
for Codea Enlightenment\
by Coding On Napkins"
.."\
Understanding\
Codea using Codea")
PatternLUAName="[_%w][_%w%d]*"
-- CHANGE THESE FOR YOUR OWN NEEDS
INITSELFS("newCode","BOX","init", -- string in [[ ]] gives parm names
[[
BOXTitle:or "Empty Title" -- comments
x: or 0
y: or HEIGHT/2
table:{a,b,c,d=e}
]]
) -- end INITSELFS call
end
function draw()
background(223, 172, 172, 255)
textMode(CORNER)
text("check new tab for code to copy paste where you need it",50,HEIGHT/2)
end
-- sets up a class function className:classFuncName(
-- and sets up self.p=p for parm in parameters
function INITSELFS(tabName,className,classFuncName,parameters)
local f = "--[====[ created by INITSELFS written by Coding On Napkins"
.."\
function "..className..":"..classFuncName.."("
local selfs=""
for k,v in string.gmatch(parameters,"("..PatternLUAName..")%:(.-)\
") do
f=f..k..","
selfs = selfs.."self."..k.." = "..k.." "..v.."\
"
end
saveProjectTab(tabName,f..")\
"..
selfs.."end -- function "..className..":"..classFuncName.."\
]====]")
end
-- set icon for project
function setProjectIcon(icontext)
pushStyle()
local iconsize=350
local img = image(iconsize,iconsize) -- or 350 on retina, 175 non-retina
setContext(img)
fill(3, 253, 90, 255)
stroke(0, 50, 255, 255)
noStroke()
rectMode(CORNER)
rect(0,0,iconsize,iconsize)
fill(0, 0, 0, 255)
textAlign(CENTER)
font("HelveticaNeue-CondensedBold")
fontSize(25)
textMode(CENTER)
text(icontext,iconsize/2,iconsize/2)
saveImage("Project:Icon", img)
setContext()
popStyle()
end