I’m not really sure what this would be useful for in practice, but it was pretty interesting to make and write for; it supports most standard terminal capabilities (colors/background inversion, input/output, etc.)
I’ll be making a tutorial for io/coroutines later, but the basics are:
function example()
-- Reads text
term.read("Enter some text: ")
coroutine.yield()
-- Prints text
term.print("You typed: " .. term.getInput())
-- Alternate read, for passwords
-- Passing true as the second parameter to term.read causes characters to be hidden
term.read("Enter your password: ", true)
coroutine.yield()
-- Prints text again
term.print("Your password is: " .. term.getInput())
end
term.coroutine = coroutine.create(example)
To download, paste this code into a new project and run it:
function setup()
spriteMode(CORNER)
http.request("https://www.dropbox.com/s/r0t447nv4hwx98r/fdata.png?dl=1", function(im)
local i = image(im.width/2,im.height/2) setContext(i) sprite(im, 0,0,im.width/2, im.height/2) setContext() saveImage("Documents:FDATA_MODES", i) print("Font saved") end, print)
http.request("https://github.com/FeynmanTech/codea-terminal/raw/master/terminal.lua",
function(data)
for tab, src in data:gmatch("%-%-%[=%[TAB:(.-)%]=%]\
(.-)%-%-%[=%[END_TAB%]=%]") do
saveProjectTab(tab, src)
end
print("Done")
restart()
end)
end
You can also download the command repo I use:
function setup()
http.request("https://github.com/FeynmanTech/codea-terminal/raw/master/cmd.lua",
function(data)
for tab, src in data:gmatch("%-%-%[=%[TAB:(.-)%]=%]\
(.-)%-%-%[=%[END_TAB%]=%]") do
saveProjectTab(tab, src)
end
end)
end
After creating that project, set it as the cmd project during setup, and it will be loaded on startup. There’s a wide variety of programs there, encompassing the entirety of the terminal’s capabilities, so it could be a good starter for boilerplate code
EDIT: I’ve updated the main source and the font, adding bolded text and fixing a few things.