Skip to content

Commit 4aeff01

Browse files
committed
Merge branch 'main' into gradle-runner
2 parents 046a216 + 72db9b7 commit 4aeff01

File tree

19 files changed

+299
-141
lines changed

19 files changed

+299
-141
lines changed

.all-contributorsrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,6 +1651,24 @@
16511651
"contributions": [
16521652
"code"
16531653
]
1654+
},
1655+
{
1656+
"login": "npNSU",
1657+
"name": "Nia Perez",
1658+
"avatar_url": "https://avatars.githubusercontent.com/u/179620963?v=4",
1659+
"profile": "https://github.com/npNSU",
1660+
"contributions": [
1661+
"code"
1662+
]
1663+
},
1664+
{
1665+
"login": "SuganthiThomas",
1666+
"name": "SuganthiThomas",
1667+
"avatar_url": "https://avatars.githubusercontent.com/u/150956406?v=4",
1668+
"profile": "https://github.com/SuganthiThomas",
1669+
"contributions": [
1670+
"code"
1671+
]
16541672
}
16551673
],
16561674
"repoType": "github",

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,10 @@ _Note: due to GitHub's limitations, this repository's [Contributors](https://git
315315
<td align="center" valign="top" width="16.66%"><a href="https://github.com/manoellribeiro"><img src="https://avatars.githubusercontent.com/u/59377764?v=4?s=120" width="120px;" alt="Manoel Ribeiro"/><br /><sub><b>Manoel Ribeiro</b></sub></a><br /><a href="https://github.com/processing/processing4/commits?author=manoellribeiro" title="Documentation">📖</a></td>
316316
<td align="center" valign="top" width="16.66%"><a href="https://softmoon.world"><img src="https://avatars.githubusercontent.com/u/15107?v=4?s=120" width="120px;" alt="Moon"/><br /><sub><b>Moon</b></sub></a><br /><a href="https://github.com/processing/processing4/commits?author=catilac" title="Code">💻</a></td>
317317
</tr>
318+
<tr>
319+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/npNSU"><img src="https://avatars.githubusercontent.com/u/179620963?v=4?s=120" width="120px;" alt="Nia Perez"/><br /><sub><b>Nia Perez</b></sub></a><br /><a href="https://github.com/processing/processing4/commits?author=npNSU" title="Code">💻</a></td>
320+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/SuganthiThomas"><img src="https://avatars.githubusercontent.com/u/150956406?v=4?s=120" width="120px;" alt="SuganthiThomas"/><br /><sub><b>SuganthiThomas</b></sub></a><br /><a href="https://github.com/processing/processing4/commits?author=SuganthiThomas" title="Code">💻</a></td>
321+
</tr>
318322
</tbody>
319323
</table>
320324

app/src/processing/app/Base.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ public class Base {
6565
* if an empty file named 'debug' is found in the settings folder.
6666
* See implementation in createAndShowGUI().
6767
*/
68-
static public boolean DEBUG = System.getenv().containsKey("DEBUG");
68+
69+
static public boolean DEBUG = Boolean.parseBoolean(System.getenv().getOrDefault("DEBUG", "false"));
70+
6971

7072
/** True if running via Commander. */
7173
static private boolean commandLine;

app/src/processing/app/Processing.kt

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,28 @@ import com.github.ajalt.clikt.parameters.options.help
1212
import com.github.ajalt.clikt.parameters.options.option
1313
import processing.app.gradle.api.Sketch
1414
import processing.app.api.Contributions
15+
import processing.app.api.SketchCommand
1516
import processing.app.api.Sketchbook
1617
import processing.app.ui.Start
1718
import java.io.File
1819
import java.util.prefs.Preferences
1920
import kotlin.concurrent.thread
2021

21-
class Processing: SuspendingCliktCommand("processing"){
22-
val version by option("-v","--version")
22+
23+
suspend fun main(args: Array<String>) {
24+
Processing()
25+
.subcommands(
26+
LSP(),
27+
LegacyCLI(args),
28+
Contributions(),
29+
Sketchbook(),
30+
SketchCommand()
31+
)
32+
.main(args)
33+
}
34+
35+
class Processing : SuspendingCliktCommand("processing") {
36+
val version by option("-v", "--version")
2337
.flag()
2438
.help("Print version information")
2539

@@ -30,7 +44,7 @@ class Processing: SuspendingCliktCommand("processing"){
3044
override fun help(context: Context) = "Start the Processing IDE"
3145
override val invokeWithoutSubcommand = true
3246
override suspend fun run() {
33-
if(version){
47+
if (version) {
3448
println("processing-${Base.getVersionName()}-${Base.getRevision()}")
3549
return
3650
}
@@ -47,21 +61,10 @@ class Processing: SuspendingCliktCommand("processing"){
4761
}
4862
}
4963

50-
suspend fun main(args: Array<String>){
51-
Processing()
52-
.subcommands(
53-
LSP(),
54-
LegacyCLI(args),
55-
Sketch(),
56-
Contributions(),
57-
Sketchbook()
58-
)
59-
.main(args)
60-
}
6164

62-
class LSP: SuspendingCliktCommand("lsp"){
65+
class LSP : SuspendingCliktCommand("lsp") {
6366
override fun help(context: Context) = "Start the Processing Language Server"
64-
override suspend fun run(){
67+
override suspend fun run() {
6568
try {
6669
// run in headless mode
6770
System.setProperty("java.awt.headless", "true")
@@ -76,8 +79,7 @@ class LSP: SuspendingCliktCommand("lsp"){
7679
}
7780
}
7881

79-
80-
class LegacyCLI(val args: Array<String>): SuspendingCliktCommand("cli") {
82+
class LegacyCLI(val args: Array<String>) : SuspendingCliktCommand("cli") {
8183
override val treatUnknownOptionsAsArgs = true
8284

8385
val help by option("--help").flag()
@@ -97,35 +99,35 @@ class LegacyCLI(val args: Array<String>): SuspendingCliktCommand("cli") {
9799
}
98100
}
99101

100-
fun updateInstallLocations(){
102+
fun updateInstallLocations() {
101103
val preferences = Preferences.userRoot().node("org/processing/app")
102104
val installLocations = preferences.get("installLocations", "")
103105
.split(",")
104106
.dropLastWhile { it.isEmpty() }
105107
.filter { install ->
106-
try{
108+
try {
107109
val (path, version) = install.split("^")
108110
val file = File(path)
109-
if(!file.exists() || file.isDirectory){
111+
if (!file.exists() || file.isDirectory) {
110112
return@filter false
111113
}
112114
// call the path to check if it is a valid install location
113115
val process = ProcessBuilder(path, "--version")
114116
.redirectErrorStream(true)
115117
.start()
116118
val exitCode = process.waitFor()
117-
if(exitCode != 0){
119+
if (exitCode != 0) {
118120
return@filter false
119121
}
120122
val output = process.inputStream.bufferedReader().readText()
121123
return@filter output.contains(version)
122-
} catch (e: Exception){
124+
} catch (e: Exception) {
123125
false
124126
}
125127
}
126128
.toMutableList()
127129
val command = ProcessHandle.current().info().command()
128-
if(command.isEmpty) {
130+
if (command.isEmpty) {
129131
return
130132
}
131133
val installLocation = "${command.get()}^${Base.getVersionName()}"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package processing.app.api
2+
3+
import com.github.ajalt.clikt.command.SuspendingCliktCommand
4+
import com.github.ajalt.clikt.core.Context
5+
import com.github.ajalt.clikt.core.subcommands
6+
import com.github.ajalt.clikt.parameters.arguments.argument
7+
import com.github.ajalt.clikt.parameters.arguments.help
8+
import com.github.ajalt.clikt.parameters.options.flag
9+
import com.github.ajalt.clikt.parameters.options.help
10+
import com.github.ajalt.clikt.parameters.options.option
11+
import processing.app.Language
12+
import processing.app.Platform
13+
import processing.app.Preferences
14+
import java.io.File
15+
16+
class SketchCommand: SuspendingCliktCommand("sketch"){
17+
override fun help(context: Context) = "Manage a Processing sketch"
18+
override suspend fun run() {
19+
20+
}
21+
init {
22+
subcommands(Format())
23+
}
24+
25+
class Format: SuspendingCliktCommand("format"){
26+
override fun help(context: Context) = "Format a Processing sketch"
27+
val file by argument("file")
28+
.help("Path to the sketch file to format")
29+
val inPlace by option("-i","--inplace")
30+
.flag()
31+
.help("Format the file in place, otherwise prints to stdout")
32+
33+
override suspend fun run(){
34+
try {
35+
Platform.init()
36+
Language.init()
37+
Preferences.init()
38+
39+
// run in headless mode
40+
System.setProperty("java.awt.headless", "true")
41+
42+
val clazz = Class.forName("processing.mode.java.AutoFormat")
43+
// Indirect invocation since app does not depend on java mode
44+
val formatter = clazz
45+
.getDeclaredConstructor()
46+
.newInstance()
47+
48+
val method = clazz.getMethod("format", String::class.java)
49+
val code = File(file).readText()
50+
51+
val formatted = method.invoke(formatter, code) as String
52+
if(inPlace) {
53+
File(file).writeText(formatted)
54+
return
55+
}
56+
println(formatted)
57+
} catch (e: Exception) {
58+
throw InternalError("Failed to invoke main method", e)
59+
}
60+
}
61+
}
62+
}

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

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,7 @@
4949
import javax.swing.undo.*;
5050

5151
import com.formdev.flatlaf.util.SystemInfo;
52-
import processing.app.Base;
53-
import processing.app.Formatter;
54-
import processing.app.Language;
55-
import processing.app.Messages;
56-
import processing.app.Mode;
57-
import processing.app.Platform;
58-
import processing.app.Preferences;
59-
import processing.app.Problem;
60-
import processing.app.RunnerListener;
61-
import processing.app.Sketch;
62-
import processing.app.SketchCode;
52+
import processing.app.*;
6353
import processing.utils.SketchException;
6454
import processing.app.contrib.ContributionManager;
6555
import processing.app.gradle.GradleService;
@@ -148,6 +138,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
148138
private FindReplace find;
149139
JMenu toolsMenu;
150140
JMenu modePopup;
141+
JMenu developMenu;
151142

152143
protected List<Problem> problems = Collections.emptyList();
153144

@@ -689,6 +680,7 @@ protected void buildMenuBar() {
689680
helpMenu.setText(helpMenu.getText() + " ");
690681
}
691682
menubar.add(helpMenu);
683+
updateDevelopMenu(menubar);
692684

693685
Toolkit.setMenuMnemonics(menubar);
694686
setJMenuBar(menubar);
@@ -1069,6 +1061,37 @@ public JMenu buildModeMenu() {
10691061

10701062
abstract public JMenu buildHelpMenu();
10711063

1064+
public void buildDevelopMenu(){
1065+
developMenu = new JMenu(Language.text("menu.develop"));
1066+
1067+
var updateTrigger = new JMenuItem(Language.text("menu.develop.check_for_updates"));
1068+
updateTrigger.addActionListener(e -> {
1069+
Preferences.unset("update.last");
1070+
new UpdateCheck(base);
1071+
});
1072+
developMenu.add(updateTrigger);
1073+
1074+
}
1075+
1076+
public void updateDevelopMenu(){
1077+
updateDevelopMenu(null);
1078+
}
1079+
1080+
void updateDevelopMenu(JMenuBar menu){
1081+
if(menu == null){
1082+
menu = getJMenuBar();
1083+
}
1084+
if(developMenu == null){
1085+
buildDevelopMenu();
1086+
}
1087+
if(Base.DEBUG){
1088+
menu.add(developMenu);
1089+
}else{
1090+
menu.remove(developMenu);
1091+
}
1092+
1093+
}
1094+
10721095

10731096
public void showReference(String filename) {
10741097
File file = new File(mode.getReferenceFolder(), filename);

app/src/processing/app/ui/EditorFooter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public EditorFooter(Editor eddie) {
116116
public void mousePressed(MouseEvent e) {
117117
if(e.getClickCount() == 5){
118118
Base.DEBUG = !Base.DEBUG;
119+
editor.updateDevelopMenu();
119120
}
120121
var debugInformation = String.join("\n",
121122
"Version: " + Base.getVersionName(),

build.gradle.kts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ plugins {
44

55
alias(libs.plugins.compose.compiler) apply false
66
alias(libs.plugins.jetbrainsCompose) apply false
7+
8+
alias(libs.plugins.versions)
79
}
810

911
// Set the build directory to not /build to prevent accidental deletion through the clean action
@@ -17,4 +19,20 @@ allprojects{
1719
tasks.withType<Javadoc> {
1820
options.encoding = "UTF-8"
1921
}
20-
}
22+
}
23+
// Configure the dependencyUpdates task
24+
tasks {
25+
dependencyUpdates {
26+
gradleReleaseChannel = "current"
27+
28+
val nonStableKeywords = listOf("alpha", "beta", "rc")
29+
30+
fun isNonStable(version: String) = nonStableKeywords.any {
31+
version.lowercase().contains(it)
32+
}
33+
34+
rejectVersionIf {
35+
isNonStable(candidate.version) && !isNonStable(currentVersion)
36+
}
37+
}
38+
}

build/shared/lib/languages/PDE.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ menu.help.visit.url = https://processing.org/
172172
menu.help.report.url = https://github.com/processing/processing4/issues
173173
menu.help.ask.url = https://discourse.processing.org
174174

175+
menu.develop = Develop
176+
menu.develop.check_for_updates = Force Check for updates
175177

176178
# ---------------------------------------
177179
# Basics

core/src/processing/core/PApplet.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,7 @@ public PSurface getSurface() {
802802
// Unlike the others above, needs to be public to support
803803
// the pixelWidth and pixelHeight fields.
804804
public int pixelDensity = 1;
805+
boolean pixelDensityWarning = false;
805806

806807
boolean present;
807808

@@ -1082,6 +1083,9 @@ public int displayDensity(int display) {
10821083
*/
10831084
public void pixelDensity(int density) {
10841085
//println(density + " " + this.pixelDensity);
1086+
1087+
1088+
this.pixelDensityWarning = false;
10851089
if (density != this.pixelDensity) {
10861090
if (insideSettings("pixelDensity", density)) {
10871091
if (density != 1 && density != 2) {
@@ -2050,6 +2054,10 @@ public void handleDraw() {
20502054
if (frameCount == 0) {
20512055
setup();
20522056

2057+
if(pixelDensityWarning){
2058+
System.err.println("Warning: Processing now sets pixelDensity(2) by default on high-density screens. This may change how your sketch looks. To revert to the old behavior, set pixelDensity(1) in setup().");
2059+
}
2060+
20532061
} else { // frameCount > 0, meaning an actual draw()
20542062
// update the current frameRate
20552063

@@ -10108,6 +10116,7 @@ static public void runSketch(final String[] args,
1010810116
sketch.fullScreen = fullScreen;
1010910117

1011010118
sketch.pixelDensity = sketch.displayDensity();
10119+
sketch.pixelDensityWarning = sketch.pixelDensity > 1;
1011110120

1011210121
// For 3.0.1, moved this above handleSettings() so that loadImage() can be
1011310122
// used inside settings(). Sets a terrible precedent, but the alternative

0 commit comments

Comments
 (0)