Skip to content

Commit

Permalink
Merge pull request #1 from processing/main
Browse files Browse the repository at this point in the history
Sync up to upstream main
  • Loading branch information
sampottinger authored Jul 24, 2023
2 parents e541663 + aab93fd commit eddab45
Show file tree
Hide file tree
Showing 24 changed files with 294 additions and 300 deletions.
16 changes: 13 additions & 3 deletions app/src/processing/app/Language.java
Original file line number Diff line number Diff line change
Expand Up @@ -351,24 +351,34 @@ static class LanguageBundle {
LanguageBundle(String language) throws IOException {
table = new HashMap<>();

// Also check to see if the user is working on localization,
// and has their own .properties files in their sketchbook.
// https://github.com/processing/processing4/wiki/Translations
// Disabling load from sketchbook in 4.2.1, because the path
// is not yet loaded from Preferences when languages are loaded.
// Fixing that (i.e. reloading languages) makes the code a lot
// more complicated for dubious benefit over simply editing the
// language files in the download (i.e. still would not help
// with adding new language codes.)

String baseFilename = "languages/PDE.properties";
String langFilename = "languages/PDE_" + language + ".properties";

File baseFile = Base.getLibFile(baseFilename);
/*
// Also check to see if the user is working on localization,
// and has their own .properties files in their sketchbook.
// https://github.com/processing/processing4/wiki/Translations
File userBaseFile = new File(Base.getSketchbookFolder(), baseFilename);
if (userBaseFile.exists()) {
baseFile = userBaseFile;
}
*/

File langFile = Base.getLibFile(langFilename);
/*
File userLangFile = new File(Base.getSketchbookFolder(), langFilename);
if (userLangFile.exists()) {
langFile = userLangFile;
}
*/

read(baseFile);
read(langFile);
Expand Down
58 changes: 4 additions & 54 deletions app/src/processing/app/Problem.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,6 @@
*/
public interface Problem {

/**
* Strategy converting line number in tab to character offset from tab start.
*/
public interface LineToTabOffsetGetter {

/**
* Convert a line number to the number of characters past tab start.
*
* @param line The line number to convert.
* @return The number of characters past tab start where that line starts.
*/
public int get(int line);

}

/**
* Get if the problem is an error that prevented compilation.
*
Expand Down Expand Up @@ -81,56 +66,21 @@ public interface LineToTabOffsetGetter {
*/
public String getMessage();

/**
* Get the exact character on which this problem starts in code tab relative.
*
* @return Number of characters past the start of the tab if known where the
* code associated with the Problem starts. Returns empty if not provided.
*/
public Optional<Integer> getTabStartOffset();

/**
* Get the exact character on which this problem ends in code tab relative.
*
* @return Number of characters past the start of the tab if known where the
* code associated with the Problem ends. Returns empty if not provided.
*/
public Optional<Integer> getTabStopOffset();

/**
* Get the exact character on which this problem starts in code line relative.
*
* @return Number of characters past the start of the line if known where the
* code associated with the Problem starts. Returns empty if not provided.
* code associated with the Problem starts.
*/
public Optional<Integer> getLineStartOffset();
public int getStartOffset();

/**
* Get the exact character on which this problem ends in code line relative.
*
* @return Number of characters past the start of the line if known where the
* code associated with the Problem ends. Returns empty if not provided.
*/
public Optional<Integer> getLineStopOffset();

/**
* Get the exact character on which this problem ends in code tab relative.
*
* @param strategy Strategy to convert line to tab start if needed.
* @return Number of characters past the start of the tab if known where the
* code associated with the Problem ends, using the provided conversion
* if needed. Returns line start if character position not given.
* code associated with the Problem ends.
*/
public int computeTabStartOffset(LineToTabOffsetGetter strategy);
public int getStopOffset();

/**
* Get the exact character on which this problem ends in code tab relative.
*
* @param strategy Strategy to convert line to tab start if needed.
* @return Number of characters past the start of the tab if known where the
* code associated with the Problem ends, using the provided conversion
* if needed. Returns line start if character position not given.
*/
public int computeTabStopOffset(LineToTabOffsetGetter strategy);
}

17 changes: 4 additions & 13 deletions app/src/processing/app/syntax/PdeTextAreaPainter.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ public class PdeTextAreaPainter extends TextAreaPainter {
protected Color gutterTextInactiveColor;
protected Color gutterHighlightColor;

private final Problem.LineToTabOffsetGetter lineToTabOffsetGetter;


public PdeTextAreaPainter(JEditTextArea textArea, TextAreaDefaults defaults) {
super(textArea, defaults);
Expand Down Expand Up @@ -78,10 +76,6 @@ public void mousePressed(MouseEvent event) {
}
}
});

lineToTabOffsetGetter = (x) -> {
return textArea.getLineStartOffset(x);
};
}


Expand Down Expand Up @@ -153,14 +147,11 @@ protected void paintLine(Graphics gfx, int line, int x, TokenMarkerState marker)
protected void paintErrorLine(Graphics gfx, int line, int x) {
List<Problem> problems = getEditor().findProblems(line);
for (Problem problem : problems) {
int startOffset = problem.computeTabStartOffset(lineToTabOffsetGetter);
int stopOffset = problem.computeTabStopOffset(lineToTabOffsetGetter);

int lineOffsetStart = textArea.getLineStartOffset(line);
int lineOffsetStop = textArea.getLineStopOffset(line);

int wiggleStart = Math.max(startOffset, lineOffsetStart);
int wiggleStop = Math.min(stopOffset, lineOffsetStop);
int wiggleStart = lineOffsetStart + problem.getStartOffset();
int wiggleStop = lineOffsetStart + problem.getStopOffset();

int y = textArea.lineToY(line) + getLineDisplacement();

Expand Down Expand Up @@ -338,8 +329,8 @@ public String getToolTipText(MouseEvent event) {
int lineStart = textArea.getLineStartOffset(line);
int lineEnd = textArea.getLineStopOffset(line);

int errorStart = problem.computeTabStartOffset(lineToTabOffsetGetter);
int errorEnd = problem.computeTabStopOffset(lineToTabOffsetGetter) + 1;
int errorStart = lineStart + problem.getStartOffset();
int errorEnd = lineStart + problem.getStopOffset();

int startOffset = Math.max(errorStart, lineStart) - lineStart;
int stopOffset = Math.min(errorEnd, lineEnd) - lineStart;
Expand Down
25 changes: 12 additions & 13 deletions app/src/processing/app/ui/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2556,16 +2556,16 @@ public void updateErrorTable(List<Problem> problems) {


public void highlight(Problem p) {
Problem.LineToTabOffsetGetter getter = (x) -> {
return textarea.getLineStartOffset(x);
};

if (p != null) {
int tabIndex = p.getTabIndex();
int tabToStartOffset = p.computeTabStartOffset(getter);
int tabToStopOffset = p.computeTabStopOffset(getter);
highlight(tabIndex, tabToStartOffset, tabToStopOffset);
if (p == null) {
return;
}

int tabIndex = p.getTabIndex();
int lineNumber = p.getLineNumber();
int lineStart = textarea.getLineStartOffset(lineNumber);
int tabToStartOffset = lineStart + p.getStartOffset();
int tabToStopOffset = lineStart + p.getStopOffset();
highlight(tabIndex, tabToStartOffset, tabToStopOffset);
}


Expand Down Expand Up @@ -2630,11 +2630,10 @@ public List<Problem> findProblems(int line) {
.filter(p -> p.getTabIndex() == currentTab)
.filter(p -> {
int pStartLine = p.getLineNumber();
int pEndOffset = p.computeTabStopOffset(
(startLine) -> textarea.getLineStartOffset(pStartLine)
);
int lineOffset = textarea.getLineStartOffset(pStartLine);
int pEndOffset = lineOffset + p.getStopOffset();
int pEndLine = textarea.getLineOfOffset(pEndOffset);

return line >= pStartLine && line <= pEndLine;
})
.collect(Collectors.toList());
Expand Down
30 changes: 12 additions & 18 deletions build/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,8 @@
<option value="-Dcom.apple.macos.use-file-dialog-packages=true" />
<option value="-Dcom.apple.macos.useScreenMenuBar=true" />
<option value="-Dcom.apple.smallTabs=true" />
<!-- https://github.com/processing/processing4/issues/699 -->
<option value="-Dapple.awt.application.appearance=system" />

<!-- https://github.com/jdf/Processing.py-Bugs/issues/322 -->
<option value="-Dpython.console.encoding=UTF-8" />
Expand Down Expand Up @@ -1500,18 +1502,18 @@
<mkdir dir="javadoc" />

<!-- Core is in the classpath, so we must build it. -->
<subant buildpath="../core" target="build" failonerror="false" />
<subant buildpath="../core" target="build" failonerror="true" />

<!-- build doc for core -->
<exec executable="find" dir="javadoc" errorproperty="ignored">
<exec executable="find" dir="javadoc" discardError="true">
<arg line="core -type f -exec rm -rf {} ';'" />
</exec>

<javadoc access="public" author="false" classpath="../core/library/jogl-all.jar:../core/bin:../core/library/gluegen-rt.jar" destdir="javadoc/core" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" source="17" splitindex="false" use="false" version="false">
<javadoc access="public" author="false" classpath="../core/library/jogl-all.jar:../core/bin:../core/library/gluegen-rt.jar" destdir="javadoc/core" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" source="${jdk.train}" splitindex="false" use="false" version="false">

<!-- provide links for java.* classes.
also suppresses the java.lang prefix in the text. -->
<link href="https://docs.oracle.com/en/java/javase/11/docs/api/" />
<link href="https://docs.oracle.com/en/java/javase/${jdk.train}/docs/api/" />

<!-- prevent files from always appearing to have changed -->
<arg value="-notimestamp" />
Expand All @@ -1534,32 +1536,24 @@

</javadoc>

<!--
<copy file="javadoc/stylesheet.css"
tofile="javadoc/core/stylesheet.css" />
<copy file="javadoc/index.html"
tofile="javadoc/core/index.html" />
-->

<!-- build everything else -->
<exec executable="find" dir="javadoc" errorproperty="ignored">
<exec executable="find" dir="javadoc" discardError="true">
<arg line="everything -type f -exec rm -rf {} ';'" />
</exec>

<javadoc access="public" author="false" classpath="../app/lib/ant.jar:../app/lib/ant-launcher.jar:../app/lib/jna.jar:../app/lib/jna-platform.jar:../core/bin:../core/library/gluegen-rt.jar:../core/library/jogl-all.jar:../java/libraries/svg:../java/libraries/pdf/library/itext.jar:../java/libraries/dxf:../java/libraries/serial/library:${java.home}/lib/tools.jar" destdir="javadoc/everything" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" source="17" splitindex="false" use="false" version="false" noqualifier="all">
<javadoc access="public" author="false" classpath="../app/lib/ant.jar:../app/lib/ant-launcher.jar:../app/lib/jna.jar:../app/lib/jna-platform.jar:../app/lib/flatlaf.jar:../core/bin:../core/library/gluegen-rt.jar:../core/library/jogl-all.jar:../java/libraries/svg:../java/libraries/pdf/library/itext.jar:../java/libraries/dxf:../java/libraries/serial/library:${java.home}/lib/tools.jar" destdir="javadoc/everything" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" source="${jdk.train}" splitindex="false" use="false" version="false" noqualifier="all">

<arg value="-notimestamp" />

<arg value="-quiet" />

<link href="https://docs.oracle.com/en/java/javase/11/docs/api/" />
<link href="https://docs.oracle.com/en/java/javase/${jdk.train}/docs/api/" />

<packageset dir="../app/src">
<include name="antlr/**" />
<include name="processing/**" />
</packageset>


<tag name="webref" enabled="false" />
<tag name="nowebref" enabled="false" />
<tag name="generate" enabled="false" />
Expand All @@ -1580,17 +1574,17 @@


<!-- do libraries -->
<exec executable="find" dir="javadoc" errorproperty="ignored">
<exec executable="find" dir="javadoc" discardError="true">
<arg line="libraries -type f -exec rm -rf {} ';'" />
</exec>

<javadoc access="public" author="false" classpath="../app/lib/ant.jar:../app/lib/ant-launcher.jar:../app/lib/jna.jar:../app/lib/jna-platform.jar:../core/bin:../core/library/gluegen-rt.jar:../core/library/jogl-all.jar:../java/libraries/svg/library/batik.jar:../java/libraries/pdf/library/itext.jar:../java/libraries/dxf:../java/libraries/serial/library/jssc.jar:${java.home}/lib/tools.jar" destdir="javadoc/libraries" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" source="17" splitindex="false" use="false" version="false" noqualifier="all">
<javadoc access="public" author="false" classpath="../app/lib/ant.jar:../app/lib/ant-launcher.jar:../app/lib/jna.jar:../app/lib/jna-platform.jar:../core/bin:../core/library/gluegen-rt.jar:../core/library/jogl-all.jar:../java/libraries/svg/library/batik.jar:../java/libraries/pdf/library/itext.jar:../java/libraries/dxf:../java/libraries/serial/library/jssc.jar:${java.home}/lib/tools.jar" destdir="javadoc/libraries" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" source="${jdk.train}" splitindex="false" use="false" version="false" noqualifier="all">

<arg value="-notimestamp" />

<arg value="-quiet" />

<link href="https://docs.oracle.com/en/java/javase/11/docs/api/" />
<link href="https://docs.oracle.com/en/java/javase/${jdk.train}/docs/api/" />
<link href="../../javadoc/core/" />

<tag name="webref" enabled="false" />
Expand Down
3 changes: 2 additions & 1 deletion build/shared/lib/languages/PDE_ca.properties
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ menu.help.about = Quant al Processing
menu.help.environment = Entorn de desenvolupament
menu.help.reference = Referència
menu.help.find_in_reference = Cerca en la referència
menu.help.reference.download = Descarrega la referència
menu.help.libraries_reference = Referències de les biblioteques
menu.help.tools_reference = Referències de les eines
menu.help.empty = (buit)
Expand Down Expand Up @@ -561,7 +562,7 @@ contrib.progress.installing = S'està instal·lant
contrib.progress.starting = Començant instal·lació
contrib.progress.downloading = Descarregant
contrib.download_error = S'ha produït un error durant la descàrrega de la contribució.
contrib.unsupported_operating_system = Sembla que el vostre sistema operatiu no és compatible. Consulteu la biblioteca de «%s» per a més informació.
contrib.missing_link = No s'ha trobat l'enllaç de descàrrega per a %s, contacteu amb l'autor.
contrib.category.3d = 3D
contrib.category.animation = Animació
contrib.category.data = Dades
Expand Down
3 changes: 2 additions & 1 deletion build/shared/lib/languages/PDE_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ menu.help.about = Acerca de Processing
menu.help.environment = Entorno de desarrollo
menu.help.reference = Referencia
menu.help.find_in_reference = Buscar en la referencia
menu.help.reference.download = Descargar la referencia
menu.help.libraries_reference = Referencias de bibliotecas
menu.help.tools_reference = Referencias de herramientas
menu.help.empty = (vacío)
Expand Down Expand Up @@ -561,7 +562,7 @@ contrib.progress.installing = Instalando
contrib.progress.starting = Comenzando
contrib.progress.downloading = Descargando
contrib.download_error = Ha ocurrido un error durante la descarga de la contribución.
contrib.unsupported_operating_system = Parece que este sistema operativo no es compatible. Consulta la biblioteca de «%s» para más información.
contrib.missing_link = No se ha encontrado el enlace de descarga de %s, contacta con el autor.
contrib.category.3d = 3D
contrib.category.animation = Animación
contrib.category.data = Datos
Expand Down
1 change: 1 addition & 0 deletions build/shared/lib/languages/PDE_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ menu.edit.paste = Coller
menu.edit.select_all = Sélectionner tout
menu.edit.auto_format = Mise en forme automatique
menu.edit.comment_uncomment = Commenter/Décommenter
menu.edit.comment_uncomment.keystroke = meta pressed COLON
menu.edit.increase_indent = → Augmenter l'indentation
menu.edit.decrease_indent = ← Diminuer l'indentation
menu.edit.find = Rechercher...
Expand Down
Loading

0 comments on commit eddab45

Please sign in to comment.