Skip to content

Commit c7ce229

Browse files
committed
WIP, would gp -f to override
1 parent 9604b0d commit c7ce229

File tree

8 files changed

+349
-0
lines changed

8 files changed

+349
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package rprocessing.mode;
2+
3+
/**
4+
*
5+
* @author github.com/gaocegege
6+
*/
7+
public enum DisplayType {
8+
WINDOWED, PRESENTATION;
9+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
package rprocessing.mode;
2+
3+
import javax.swing.JMenu;
4+
5+
import processing.app.Base;
6+
import processing.app.Formatter;
7+
import processing.app.Mode;
8+
import processing.app.ui.Editor;
9+
import processing.app.ui.EditorException;
10+
import processing.app.ui.EditorState;
11+
import processing.app.ui.EditorToolbar;
12+
13+
/**
14+
*
15+
* @author github.com/gaocegege
16+
*/
17+
public class RLangEditor extends Editor {
18+
19+
/** */
20+
private static final long serialVersionUID = -5993950683909551427L;
21+
22+
/**
23+
* @param base
24+
* @param path
25+
* @param state
26+
* @param mode
27+
* @throws EditorException
28+
*/
29+
protected RLangEditor(Base base, String path, EditorState state, Mode mode)
30+
throws EditorException {
31+
super(base, path, state, mode);
32+
}
33+
34+
/**
35+
* @see processing.app.ui.Editor#buildFileMenu()
36+
*/
37+
@Override
38+
public JMenu buildFileMenu() {
39+
return null;
40+
}
41+
42+
/**
43+
* @see processing.app.ui.Editor#buildHelpMenu()
44+
*/
45+
@Override
46+
public JMenu buildHelpMenu() {
47+
return null;
48+
}
49+
50+
/**
51+
* @see processing.app.ui.Editor#buildSketchMenu()
52+
*/
53+
@Override
54+
public JMenu buildSketchMenu() {
55+
return null;
56+
}
57+
58+
/**
59+
* @see processing.app.ui.Editor#createFormatter()
60+
*/
61+
@Override
62+
public Formatter createFormatter() {
63+
return null;
64+
}
65+
66+
/**
67+
* @see processing.app.ui.Editor#createToolbar()
68+
*/
69+
@Override
70+
public EditorToolbar createToolbar() {
71+
return null;
72+
}
73+
74+
/**
75+
* @see processing.app.ui.Editor#deactivateRun()
76+
*/
77+
@Override
78+
public void deactivateRun() {
79+
}
80+
81+
/**
82+
* @see processing.app.ui.Editor#getCommentPrefix()
83+
*/
84+
@Override
85+
public String getCommentPrefix() {
86+
return null;
87+
}
88+
89+
/**
90+
* @see processing.app.ui.Editor#handleImportLibrary(java.lang.String)
91+
*/
92+
@Override
93+
public void handleImportLibrary(String arg0) {
94+
}
95+
96+
/**
97+
* @see processing.app.ui.Editor#internalCloseRunner()
98+
*/
99+
@Override
100+
public void internalCloseRunner() {
101+
}
102+
103+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package rprocessing.mode;
2+
3+
import java.io.File;
4+
5+
import processing.app.Base;
6+
import processing.app.Mode;
7+
import processing.app.ui.Editor;
8+
import processing.app.ui.EditorException;
9+
import processing.app.ui.EditorState;
10+
11+
/**
12+
*
13+
* @author github.com/gaocegege
14+
*/
15+
public class RLangMode extends Mode {
16+
/**
17+
* TODO: Constructor.
18+
* @param base
19+
* @param folder
20+
*/
21+
public RLangMode(Base base, File folder) {
22+
super(base, folder);
23+
24+
}
25+
26+
public static final boolean VERBOSE = Boolean.parseBoolean(System.getenv("VERBOSE_RLANG_MODE"));
27+
28+
/**
29+
* @see processing.app.Mode#createEditor(processing.app.Base, java.lang.String, processing.app.ui.EditorState)
30+
*/
31+
@Override
32+
public Editor createEditor(Base base, final String path, final EditorState state)
33+
throws EditorException {
34+
return null;
35+
}
36+
37+
/**
38+
* @see processing.app.Mode#getDefaultExtension()
39+
*/
40+
@Override
41+
public String getDefaultExtension() {
42+
return null;
43+
}
44+
45+
/**
46+
* @see processing.app.Mode#getExtensions()
47+
*/
48+
@Override
49+
public String[] getExtensions() {
50+
return null;
51+
}
52+
53+
/**
54+
* @see processing.app.Mode#getIgnorable()
55+
*/
56+
@Override
57+
public String[] getIgnorable() {
58+
return null;
59+
}
60+
61+
/**
62+
* @see processing.app.Mode#getTitle()
63+
*/
64+
@Override
65+
public String getTitle() {
66+
return "R Language";
67+
}
68+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package rprocessing.mode.run;
2+
3+
import java.awt.Point;
4+
import java.rmi.Remote;
5+
import java.rmi.RemoteException;
6+
7+
/**
8+
*
9+
* @author github.com/gaocegege
10+
*/
11+
public interface ModeService extends Remote {
12+
void handleReady(String editorId, final SketchService service) throws RemoteException;
13+
14+
void handleSketchMoved(String editorId, final Point leftTop) throws RemoteException;
15+
16+
void handleSketchStopped(String editorId) throws RemoteException;
17+
18+
void handleSketchException(String editorId, Exception e) throws RemoteException;
19+
20+
void printStdOut(String editorId, String s) throws RemoteException;
21+
22+
void printStdErr(String editorId, String s) throws RemoteException;
23+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
package rprocessing.mode.run;
2+
3+
import java.awt.Point;
4+
import java.io.File;
5+
import java.io.Serializable;
6+
import java.util.ArrayList;
7+
import java.util.List;
8+
9+
import processing.app.Base;
10+
import processing.app.Platform;
11+
import processing.app.Sketch;
12+
import processing.core.PApplet;
13+
import rprocessing.RunnableSketch;
14+
import rprocessing.mode.DisplayType;
15+
16+
/**
17+
* A sketch run from the PDE.
18+
*
19+
* This is created in the PDE process, serialized, and then used in the sketch process.
20+
*
21+
* @author github.com/gaocegege
22+
*/
23+
@SuppressWarnings("serial")
24+
public class PdeSketch implements RunnableSketch, Serializable {
25+
26+
private final List<File> libraryDirs;
27+
private final File mainFile;
28+
private final String mainCode;
29+
private final File sketchHome;
30+
private final File realSketchPath;
31+
private final Point location;
32+
private final LocationType locationType;
33+
private final DisplayType displayType;
34+
35+
public final String[] codeFileNames; // unique to PdeSketch - leave as public field?
36+
37+
public PdeSketch(final Sketch sketch, final File sketchPath, final DisplayType displayType,
38+
final Point location, final LocationType locationType) {
39+
40+
this.displayType = displayType;
41+
this.location = location;
42+
this.locationType = locationType;
43+
44+
this.mainFile = sketchPath.getAbsoluteFile();
45+
this.mainCode = sketch.getMainProgram();
46+
this.sketchHome = sketch.getFolder().getAbsoluteFile();
47+
this.realSketchPath = sketchPath;
48+
49+
final List<File> libraryDirs = new ArrayList<>();
50+
libraryDirs.add(Platform.getContentFile("modes/java/libraries"));
51+
libraryDirs.add(Base.getSketchbookLibrariesFolder());
52+
libraryDirs.add(sketchPath);
53+
this.libraryDirs = libraryDirs;
54+
55+
final String[] codeFileNames = new String[sketch.getCodeCount()];
56+
for (int i = 0; i < codeFileNames.length; i++) {
57+
codeFileNames[i] = sketch.getCode(i).getFile().getName();
58+
}
59+
this.codeFileNames = codeFileNames;
60+
}
61+
62+
public static enum LocationType {
63+
EDITOR_LOCATION, SKETCH_LOCATION;
64+
}
65+
66+
@Override
67+
public File getMainFile() {
68+
return mainFile;
69+
}
70+
71+
@Override
72+
public String getMainCode() {
73+
return mainCode;
74+
}
75+
76+
@Override
77+
public File getHomeDirectory() {
78+
return mainFile.getParentFile();
79+
}
80+
81+
@Override
82+
public String[] getPAppletArguments() {
83+
final List<String> args = new ArrayList<>();
84+
85+
args.add(PApplet.ARGS_EXTERNAL);
86+
args.add(PApplet.ARGS_SKETCH_FOLDER + "=" + sketchHome);
87+
88+
switch (displayType) {
89+
case WINDOWED:
90+
if (locationType == LocationType.EDITOR_LOCATION) {
91+
args.add(String.format("%s=%d,%d", PApplet.ARGS_EDITOR_LOCATION, location.x,
92+
location.y));
93+
} else if (locationType == LocationType.SKETCH_LOCATION) {
94+
args.add(String.format("%s=%d,%d", PApplet.ARGS_LOCATION, location.x,
95+
location.y));
96+
}
97+
break;
98+
case PRESENTATION:
99+
args.add("fullScreen");
100+
break;
101+
}
102+
103+
args.add(mainFile.getName()); // sketch name; has to be last argument
104+
105+
return args.toArray(new String[0]);
106+
}
107+
108+
@Override
109+
public boolean shouldRun() {
110+
return true;
111+
}
112+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package rprocessing.mode.run;
2+
3+
/**
4+
*
5+
* @author github.com/gaocegege
6+
*/
7+
public class SketchRunner {
8+
9+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package rprocessing.mode.run;
2+
3+
import java.rmi.Remote;
4+
import java.rmi.RemoteException;
5+
6+
/**
7+
*
8+
* @author github.com/gaocegege
9+
*/
10+
public interface SketchService extends Remote {
11+
void startSketch(PdeSketch sketch) throws RemoteException;
12+
13+
void stopSketch() throws RemoteException;
14+
15+
void shutdown() throws RemoteException;
16+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package rprocessing.mode.run;
2+
3+
/**
4+
*
5+
* @author github.com/gaocegege
6+
*/
7+
public class SketchServiceRunner {
8+
9+
}

0 commit comments

Comments
 (0)