Skip to content

Commit 5a3f8e8

Browse files
authored
Merge branch 'processing:master' into master
2 parents 376a488 + 4ff8c25 commit 5a3f8e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+435
-255
lines changed

app/src/processing/app/Base.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,9 @@ static private void createAndShowGUI(String[] args) {
254254

255255
static private void handleWelcomeScreen(Base base) {
256256
boolean sketchbookPrompt = false;
257-
if (Preferences.getBoolean("welcome.show")) {
257+
if (Preferences.getBoolean("welcome.four.beta.show")) {
258258
// only ask once about split sketchbooks
259-
if (!Preferences.getBoolean("welcome.seen")) {
259+
if (!Preferences.getBoolean("welcome.four.beta.seen")) {
260260
// Check if there's a 2.0 sketchbook present
261261
String oldPath = Preferences.getOldSketchbookPath();
262262
if (oldPath != null) {
@@ -277,7 +277,7 @@ static private void handleWelcomeScreen(Base base) {
277277

278278
// Needs to be shown after the first editor window opens, so that it
279279
// shows up on top, and doesn't prevent an editor window from opening.
280-
if (Preferences.getBoolean("welcome.show")) {
280+
if (Preferences.getBoolean("welcome.four.beta.show")) {
281281
try {
282282
new Welcome(base, sketchbookPrompt);
283283
} catch (IOException e) {
@@ -1966,8 +1966,8 @@ static public File getSettingsFolder() {
19661966
if (!settingsFolder.mkdirs()) {
19671967
Messages.showError("Settings issues",
19681968
"Processing cannot run because it could not\n" +
1969-
"create a folder to store your settings.\n" +
1970-
settingsFolder.getAbsolutePath(), null);
1969+
"create a folder to store your settings at\n" +
1970+
settingsFolder, null);
19711971
}
19721972
}
19731973
} catch (Exception e) {

app/src/processing/app/WebServer.java

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,17 @@
1616
* <a href="http://j.mp/6BQwpI">this</a> article on java.sun.com.
1717
*/
1818
public class WebServer {
19+
static final int HTTP_OK = 200;
20+
static final int HTTP_NOT_FOUND = 404;
21+
static final int HTTP_BAD_METHOD = 405;
1922

2023
/** where worker threads stand idle */
21-
static final Vector<Worker> threads = new Vector<>();
24+
private final Vector<Worker> threads = new Vector<>();
2225

2326
/** max # worker threads */
2427
static final int WORKERS = 5;
2528

26-
/** P5 in decimal; if there are complaints, move to preferences.txt */
27-
static final int PORT = 8053;
28-
29-
static final int HTTP_OK = 200;
30-
static final int HTTP_NOT_FOUND = 404;
31-
static final int HTTP_BAD_METHOD = 405;
32-
29+
private final int port;
3330
private final ZipFile zip;
3431
private final Map<String, ZipEntry> entries;
3532

@@ -38,8 +35,10 @@ public class WebServer {
3835
static final byte[] EOL = { (byte) '\r', (byte) '\n' };
3936

4037

41-
public WebServer(String zipPath) throws IOException {
42-
zip = new ZipFile(zipPath);
38+
public WebServer(File zipFile, int port) throws IOException {
39+
this.zip = new ZipFile(zipFile);
40+
this.port = port;
41+
4342
entries = new HashMap<>();
4443
Enumeration<? extends ZipEntry> en = zip.entries();
4544
while (en.hasMoreElements()) {
@@ -57,7 +56,7 @@ public WebServer(String zipPath) throws IOException {
5756

5857
new Thread(() -> {
5958
try {
60-
ServerSocket ss = new ServerSocket(PORT);
59+
ServerSocket ss = new ServerSocket(port);
6160
while (true) {
6261
Socket s = ss.accept();
6362
synchronized (threads) {
@@ -79,6 +78,11 @@ public WebServer(String zipPath) throws IOException {
7978
}
8079

8180

81+
public String getPrefix() {
82+
return "http://localhost:" + port + "/";
83+
}
84+
85+
8286
class Worker implements Runnable {
8387
// buffer to use for requests
8488
byte[] buffer;
@@ -111,12 +115,12 @@ public synchronized void run() {
111115
// go back in wait queue if there's fewer
112116
// than numHandler connections.
113117
socket = null;
114-
synchronized (WebServer.threads) {
115-
if (WebServer.threads.size() >= WebServer.WORKERS) {
118+
synchronized (threads) {
119+
if (threads.size() >= WebServer.WORKERS) {
116120
// too many threads, exit this one
117121
return;
118122
} else {
119-
WebServer.threads.addElement(this);
123+
threads.addElement(this);
120124
}
121125
}
122126
}
@@ -320,7 +324,7 @@ void sendFile(InputStream is, PrintStream ps) throws IOException {
320324
*/
321325
static public void main(String[] args) {
322326
try {
323-
new WebServer(args[0]);
327+
new WebServer(new File(args[0]), 8053);
324328
} catch (IOException e) {
325329
e.printStackTrace();
326330
}

app/src/processing/app/platform/LinuxPlatform.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.awt.Toolkit;
2828

2929
import processing.app.Base;
30+
import processing.app.Messages;
3031
import processing.app.Preferences;
3132
import processing.core.PApplet;
3233

@@ -69,7 +70,7 @@ public String getHomeDir() {
6970
if (sudoUser != null && sudoUser.length() != 0) {
7071
try {
7172
homeDir = getHomeDir(sudoUser);
72-
} catch (Exception e) { }
73+
} catch (Exception ignored) { }
7374
}
7475
}
7576
return homeDir;
@@ -84,7 +85,25 @@ static public String getHomeDir(String user) throws Exception {
8485

8586
@Override
8687
public File getSettingsFolder() throws Exception {
87-
return new File(getHomeDir(), ".processing");
88+
// https://github.com/processing/processing4/issues/203
89+
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
90+
91+
File configHome = null;
92+
93+
// Check to see if the user has set a different location for their config
94+
String configHomeEnv = getenv("XDG_CONFIG_HOME");
95+
if (configHomeEnv != null && !configHomeEnv.isBlank()) {
96+
configHome = new File(configHomeEnv);
97+
if (!configHome.exists()) {
98+
Messages.err("XDG_CONFIG_HOME is set to " + configHomeEnv + " but does not exist.");
99+
configHome = null; // don't use non-existent folder
100+
}
101+
}
102+
// If not set properly, use the default
103+
if (configHome == null) {
104+
configHome = new File(getHomeDir(), ".config");
105+
}
106+
return new File(configHome, "processing");
88107
}
89108

90109

@@ -121,7 +140,7 @@ public boolean openFolderAvailable() {
121140
p.waitFor();
122141
Preferences.set("launcher", "xdg-open");
123142
return true;
124-
} catch (Exception e) { }
143+
} catch (Exception ignored) { }
125144

126145
// Attempt to use gnome-open
127146
try {
@@ -130,15 +149,15 @@ public boolean openFolderAvailable() {
130149
// Not installed will throw an IOException (JDK 1.4.2, Ubuntu 7.04)
131150
Preferences.set("launcher", "gnome-open");
132151
return true;
133-
} catch (Exception e) { }
152+
} catch (Exception ignored) { }
134153

135154
// Attempt with kde-open
136155
try {
137156
Process p = Runtime.getRuntime().exec(new String[] { "kde-open" });
138157
p.waitFor();
139158
Preferences.set("launcher", "kde-open");
140159
return true;
141-
} catch (Exception e) { }
160+
} catch (Exception ignored) { }
142161

143162
return false;
144163
}

app/src/processing/app/ui/Editor.java

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,80 +1049,6 @@ public JMenu buildModeMenu() {
10491049
}
10501050

10511051

1052-
/*
1053-
protected void addToolMenuItem(JMenu menu, String className) {
1054-
try {
1055-
Class<?> toolClass = Class.forName(className);
1056-
final Tool tool = (Tool) toolClass.newInstance();
1057-
1058-
JMenuItem item = new JMenuItem(tool.getMenuTitle());
1059-
1060-
tool.init(Editor.this);
1061-
1062-
item.addActionListener(new ActionListener() {
1063-
public void actionPerformed(ActionEvent e) {
1064-
EventQueue.invokeLater(tool);
1065-
}
1066-
});
1067-
menu.add(item);
1068-
1069-
} catch (Exception e) {
1070-
e.printStackTrace();
1071-
}
1072-
}
1073-
1074-
1075-
protected JMenu addInternalTools(JMenu menu) {
1076-
addToolMenuItem(menu, "processing.app.tools.CreateFont");
1077-
addToolMenuItem(menu, "processing.app.tools.ColorSelector");
1078-
addToolMenuItem(menu, "processing.app.tools.Archiver");
1079-
1080-
if (Platform.isMacOS()) {
1081-
addToolMenuItem(menu, "processing.app.tools.InstallCommander");
1082-
}
1083-
1084-
return menu;
1085-
}
1086-
*/
1087-
1088-
1089-
/*
1090-
// testing internal web server to serve up docs from a zip file
1091-
item = new JMenuItem("Web Server Test");
1092-
item.addActionListener(new ActionListener() {
1093-
public void actionPerformed(ActionEvent e) {
1094-
//WebServer ws = new WebServer();
1095-
SwingUtilities.invokeLater(new Runnable() {
1096-
public void run() {
1097-
try {
1098-
int port = WebServer.launch("/Users/fry/coconut/processing/build/shared/reference.zip");
1099-
Base.openURL("http://127.0.0.1:" + port + "/reference/setup_.html");
1100-
1101-
} catch (IOException e1) {
1102-
e1.printStackTrace();
1103-
}
1104-
}
1105-
});
1106-
}
1107-
});
1108-
menu.add(item);
1109-
*/
1110-
1111-
/*
1112-
item = new JMenuItem("Browser Test");
1113-
item.addActionListener(new ActionListener() {
1114-
public void actionPerformed(ActionEvent e) {
1115-
//Base.openURL("http://processing.org/learning/gettingstarted/");
1116-
//JFrame browserFrame = new JFrame("Browser");
1117-
BrowserStartup bs = new BrowserStartup("jar:file:/Users/fry/coconut/processing/build/shared/reference.zip!/reference/setup_.html");
1118-
bs.initUI();
1119-
bs.launch();
1120-
}
1121-
});
1122-
menu.add(item);
1123-
*/
1124-
1125-
11261052
abstract public JMenu buildHelpMenu();
11271053

11281054

@@ -2202,50 +2128,6 @@ protected void handleFindReference() {
22022128
}
22032129

22042130

2205-
/*
2206-
protected void handleFindReference() {
2207-
String text = textarea.getSelectedText().trim();
2208-
2209-
if (text.length() == 0) {
2210-
statusNotice("First select a word to find in the reference.");
2211-
2212-
} else {
2213-
char[] c = textarea.getText().toCharArray();
2214-
int after = Math.max(textarea.getSelectionStart(), textarea.getSelectionStop());
2215-
if (checkParen(c, after, c.length)) {
2216-
text += "_";
2217-
System.out.println("looking up ref for " + text);
2218-
}
2219-
String referenceFile = mode.lookupReference(text);
2220-
System.out.println("reference file is " + referenceFile);
2221-
if (referenceFile == null) {
2222-
statusNotice("No reference available for \"" + text + "\"");
2223-
} else {
2224-
showReference(referenceFile + ".html");
2225-
}
2226-
}
2227-
}
2228-
2229-
2230-
protected void handleFindReference() {
2231-
String text = textarea.getSelectedText().trim();
2232-
2233-
if (text.length() == 0) {
2234-
statusNotice("First select a word to find in the reference.");
2235-
2236-
} else {
2237-
String referenceFile = mode.lookupReference(text);
2238-
//System.out.println("reference file is " + referenceFile);
2239-
if (referenceFile == null) {
2240-
statusNotice("No reference available for \"" + text + "\"");
2241-
} else {
2242-
showReference(referenceFile + ".html");
2243-
}
2244-
}
2245-
}
2246-
*/
2247-
2248-
22492131
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22502132

22512133

build/build.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@
168168
https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.12%2B7/OpenJDK11U-jdk_x64_mac_hotspot_11.0.12_7.tar.gz
169169
-->
170170

171-
<property name="jdk.download.url" value="https://github.com/adoptium/temurin11-binaries/releases/download/jdk-${jdk.train}.${jdk.version}.${jdk.update}%2B${jdk.build}/OpenJDK11U-jdk_x64_${jdk.download.os}_hotspot_${jdk.train}.${jdk.version}.${jdk.update}_${jdk.build}.tar.gz" />
171+
<property name="jdk.download.url" value="https://github.com/adoptium/temurin11-binaries/releases/download/jdk-${jdk.train}.${jdk.version}.${jdk.update}%2B${jdk.build}/OpenJDK11U-jdk_x64_${jdk.download.os}_hotspot_${jdk.train}.${jdk.version}.${jdk.update}_${jdk.build}.${jdk.download.ext}" />
172172

173173
<get src="${jdk.download.url}"
174174
dest="${jdk.tgz.path}"
@@ -353,7 +353,8 @@
353353
<!-- don't include LWJGL, it's not operational -->
354354
<exclude name="libraries/lwjgl/**" />
355355
<exclude name="**/javafx-*sdk*.zip" />
356-
<exclude name="reference.zip" />
356+
<!-- starting with revision 1276, reference.zip stays intact -->
357+
<!-- <exclude name="reference.zip" /> -->
357358
<exclude name="**/._*" />
358359
</fileset>
359360
</copy>
@@ -375,6 +376,8 @@
375376
ignoreerrors="${reference.ignorable}"
376377
usetimestamp="true" />
377378

379+
<!-- starting with revision 1276, reference.zip stays intact -->
380+
<!--
378381
<unzip dest="${target.path}/modes/java"
379382
src="../java/reference.zip"
380383
overwrite="false">
@@ -383,14 +386,14 @@
383386
<exclude name="**/._*" />
384387
</patternset>
385388
</unzip>
389+
-->
386390

387391
<!-- copy PDE X mode folder-->
388392
<!--
389393
<copy todir="${target.path}/modes/">
390394
<fileset dir="../pdex/dist" />
391395
</copy>
392396
-->
393-
394397
</target>
395398

396399
<target name="version-clear">

0 commit comments

Comments
 (0)