processing-r / Processing.R

R Language Mode in Processing for Creative Coding, created by @gaocegege, maintained by @jeremydouglass
https://processing-r.github.io/
GNU General Public License v3.0
144 stars 16 forks source link

Support sketches #21

Open gaocegege opened 7 years ago

gaocegege commented 7 years ago

Processing.R does not have the concept about sketch, now.

Edit:

  1. Tab contents are currently ignored by the R mode compiler -- tabs are NOT concatenated into the sketch. before compiling / running, and treated like one big text file.

  2. Creating a new Tab2 in a PDE sketch gives the error: ".r is not a valid extension"
    New tabs are possible if manually named with the extension ".rpde", and new tab contents are saved-loaded correctly when PDE saves and loads. However they are ignored as above.

jeremydouglass commented 7 years ago

Please edit the description above and explain what you mean by "support sketches" in this issue using more detail.

I'm guessing that you aren't referring to static mode or standalone sketches... do you mean something about .rpde files? or file menus in PDE? Or file type launching in desktop OSes?

gaocegege commented 7 years ago

I mean Processing supports compile multiple files in one sketch folder, and R mode does not support it.

jeremydouglass commented 7 years ago

Ah, I see what you mean.

Currently, if you try to create a new tab Tab2 in a PDE sketch, it gives the error:

".r" is not a valid extension

However, creating a new tab is possible if you name the new tab Tab2.rpde

Once the tab is created, saving the sketch correctly saves its contents. Closing and re-opening the sketch displays all .rpde tabs correctly.

HOWEVER, the contents of Tab2 are ignored on run.

The way that Processing(Java) handles this is (I believe) very simple -- the contents of all files are concatenated together before compiling / running, and treated like one big text file. The main sketch (the one with a name matching the folder name) goes first, then everything else.

gaocegege commented 7 years ago

It is a good idea. I will take a look at the implementation in Processing java mode :)

jeremydouglass commented 7 years ago

In the future we might also consider disabling the multi-tab part of the interface if we don't compile the contents of tabs.

jeremydouglass commented 5 years ago

the implementation in Processing java mode

Taking notes for myself on this -- I think that the relevant code might be here:

https://github.com/processing/processing/blob/master/java/src/processing/mode/java/JavaEditor.java

...which extends Editor, here:

https://github.com/processing/processing/blob/master/app/src/processing/app/ui/Editor.java

A tricky part about Java mode tabs is that there is a ton of code to special-case two kinds of tabs -- pde tabs, which are concatonated, and .java tabs, which are handled separately. In Processing.R it is not that complicated -- all tabs would just be R code.