Skip to content

Commit c080196

Browse files
Merge branch 'visual-testing' into pr05-visualtests
2 parents a342a77 + c1d6313 commit c080196

File tree

29 files changed

+1598
-80
lines changed

29 files changed

+1598
-80
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: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,27 @@ import com.github.ajalt.clikt.parameters.options.flag
1111
import com.github.ajalt.clikt.parameters.options.help
1212
import com.github.ajalt.clikt.parameters.options.option
1313
import processing.app.api.Contributions
14+
import processing.app.api.SketchCommand
1415
import processing.app.api.Sketchbook
1516
import processing.app.ui.Start
1617
import java.io.File
1718
import java.util.prefs.Preferences
1819
import kotlin.concurrent.thread
1920

21+
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+
2035
class Processing: SuspendingCliktCommand("processing"){
2136
val version by option("-v","--version")
2237
.flag()
@@ -46,16 +61,6 @@ class Processing: SuspendingCliktCommand("processing"){
4661
}
4762
}
4863

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

6065
class LSP: SuspendingCliktCommand("lsp"){
6166
override fun help(context: Context) = "Start the Processing Language Server"
@@ -74,7 +79,6 @@ class LSP: SuspendingCliktCommand("lsp"){
7479
}
7580
}
7681

77-
7882
class LegacyCLI(val args: Array<String>): SuspendingCliktCommand("cli") {
7983
override val treatUnknownOptionsAsArgs = true
8084

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 & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,8 @@
4848
import javax.swing.text.html.*;
4949
import javax.swing.undo.*;
5050

51-
import com.formdev.flatlaf.FlatLaf;
5251
import com.formdev.flatlaf.util.SystemInfo;
53-
import processing.app.Base;
54-
import processing.app.Formatter;
55-
import processing.app.Language;
56-
import processing.app.Messages;
57-
import processing.app.Mode;
58-
import processing.app.Platform;
59-
import processing.app.Preferences;
60-
import processing.app.Problem;
61-
import processing.app.RunnerListener;
62-
import processing.app.Sketch;
63-
import processing.app.SketchCode;
52+
import processing.app.*;
6453
import processing.utils.SketchException;
6554
import processing.app.contrib.ContributionManager;
6655
import processing.app.laf.PdeMenuItemUI;
@@ -147,6 +136,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
147136
private FindReplace find;
148137
JMenu toolsMenu;
149138
JMenu modePopup;
139+
JMenu developMenu;
150140

151141
protected List<Problem> problems = Collections.emptyList();
152142

@@ -680,6 +670,7 @@ protected void buildMenuBar() {
680670
helpMenu.setText(helpMenu.getText() + " ");
681671
}
682672
menubar.add(helpMenu);
673+
updateDevelopMenu(menubar);
683674

684675
Toolkit.setMenuMnemonics(menubar);
685676
setJMenuBar(menubar);
@@ -1060,6 +1051,37 @@ public JMenu buildModeMenu() {
10601051

10611052
abstract public JMenu buildHelpMenu();
10621053

1054+
public void buildDevelopMenu(){
1055+
developMenu = new JMenu(Language.text("menu.develop"));
1056+
1057+
var updateTrigger = new JMenuItem(Language.text("menu.develop.check_for_updates"));
1058+
updateTrigger.addActionListener(e -> {
1059+
Preferences.unset("update.last");
1060+
new UpdateCheck(base);
1061+
});
1062+
developMenu.add(updateTrigger);
1063+
1064+
}
1065+
1066+
public void updateDevelopMenu(){
1067+
updateDevelopMenu(null);
1068+
}
1069+
1070+
void updateDevelopMenu(JMenuBar menu){
1071+
if(menu == null){
1072+
menu = getJMenuBar();
1073+
}
1074+
if(developMenu == null){
1075+
buildDevelopMenu();
1076+
}
1077+
if(Base.DEBUG){
1078+
menu.add(developMenu);
1079+
}else{
1080+
menu.remove(developMenu);
1081+
}
1082+
1083+
}
1084+
10631085

10641086
public void showReference(String filename) {
10651087
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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ 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
1012
// Can be deleted after the migration to Gradle is complete
1113

12-
layout.buildDirectory = file(".build")
14+
layout.buildDirectory = file(".build")

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/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ tasks.test {
5353
}
5454
}
5555

56-
mavenPublishing {
57-
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
56+
mavenPublishing{
57+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = true)
5858
signAllPublications()
5959

6060
pom {

0 commit comments

Comments
 (0)