Codea as REPL

Hi everyone,
Peraphs someone did it, but I’ve not found related post. The idea is simple, be able to edit a project from a computer when Codea’s viewer is running. In the first time, I’ve made some tests with http request and code eval from Codea and build a simple request server on the pc. Here is the proof concept :
Sorry for the poor quality, we don’t see the first steps (create a new project, and link the lib).
For now, it can : synchronise files between the Codea and the pc, send files to the Documents folder from the pc, evaluate and save chunk of code or entire file, return print output to the pc.
I would post other video and share (when ready) it if someone is interested.

Sure i am interested! Thanks for your proposal.

AMAZING! what’s the editor your using on your mac? and when will you share this awesomeness?

That is awesome! I’d really like to see this.

I wouldn’t mind seeing this either :slight_smile:

Nice job! This is quite interesting.
I’d love to see the code.

That’s awesome!! Is it possible to do this on a windows pc too??

They are using Sublime Text 2, which I find quite nice for editing Lua on Mac.

I find it nice for just about…everything, ST2 is great.

Same here, ST2 rules.have you guys tried st3?

I’ve posted something similar in this forum about 8 month ago, using a nodejs server to serve the updated code. It is especially convenient when using the Codea runtime on an iPhone to be able to test the code easier.

Yep, ST2 is really good. I use it for this project because it’s simple to add features in real time, but I want the system to be “editor independent” (just flat files managed by the server).
@Saurabh yes, for now it’s written in python.
@tnlogy great, I’ll take a look.
I hope soon to post the sources.
Meanwhile, I came around a strange behavior. it’s a bit far fetched, but I try to explain it.
You need to have a local or remote server. Put a blank file on it (for the example mine is test_codea.txt). From Codea create a new project, add a new tab and paste the following into it:

local host = ""
local o_setup, main_tab
local function poll()    
            if o_setup then
                o_setup = nil
                f = loadstring(main_tab)
            saveProjectTab("output", data)
    if not o_setup and setup thens
        o_setup = setup
        setup = function() end
        draw = function() end

    local status, tab = pcall(readProjectTab, "Main")
    main_tab = tab
    if status then
end, "c")

Replace the host address with your’s. Create a third tab and name it output. Run the project and close it. From here, when you modify the remote file, the output tab while be modified even if your you are on the project screen of Codea. It seem that some features of the api lives out of the viewer :).

It should be possible to make it work with the “new” functionality of reading and saving project tabs, so that it keeps the tabs in the project synchronized with the files for the project on the computer. I also use a polling loop to see updates, since the lack of sockets.

@tnlogy yes I use this “new” functionality for the synchronisation. For my use case, the lack of sockets wouldn’t annoying if http requests could handle long polling (the only trick I’ve found is to return one character every n seconds from the sever, this prevent the timeout error, but as the content-length must be returned before the body, you must deal with a predifined response size / polling time).
Is it me or polling http request use the battery faster ?

Are you still working on this one? I’m very interested in trying this out :slight_smile:

Mmhh, sorry, I haven’t much time to work on it. I still create a repo on github : I hope you do not expect to much, it is at an early state, but it is good to share it now and grab feedback if possible :wink:

Thanks a lot !

@toffer I’ve been greatly inspired by your efforts with LiveCodea to add something similar to Codea. I have no idea whether it will make it into actual release (i.e., whether it will pass review, even though it’s local editing only). But it’s been fun to work on:

(Codea runs the web server and you connect to it through your PC. Then Codea serves projects that you can navigate. Opening a project in the browser also starts it running in Codea. Then you get an in-browser Lua code editor for editing the files. The changes are reflected live in the running Codea project.)

@Simeon: this sounds amazing. Fingers cross that this could pass review and make it into the app!

@Simeon Yeah! I can’t wait for that! cross my fingers too. I’ve been thinking of rewrite my experiment to a fully editor/server based on webkit-node. So, I wait and see If it pass the review. Do you plan to submit it in the current beta ?