Open gaocegege opened 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?
I mean Processing supports compile multiple files in one sketch folder, and R mode does not support it.
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.
It is a good idea. I will take a look at the implementation in Processing java mode :)
In the future we might also consider disabling the multi-tab part of the interface if we don't compile the contents of tabs.
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.
Processing.R does not have the concept about sketch, now.
Edit:
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.
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.