Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Handle CR without NL printed in EditorConsole #9954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
EditorConsole: Set up System.out/err redirection in setCurrentEditorC…
…onsole

Previously, the redirection would be triggered in the EditorConsole
constructor. However, this was problematic for unittests, which do not
need this redirection.

Since the redirection really is not useful intul there is a current
EditorConsole anyway, it can just be delayed a bit until
setCurrentEditorConsole is called.
  • Loading branch information
matthijskooijman committed May 7, 2020
commit cd11c2d88a8086e0bdc93da8412e4169b4adc3a4
26 changes: 11 additions & 15 deletions 26 app/src/processing/app/EditorConsole.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,15 @@ public class EditorConsole extends JScrollPane {
private static ConsoleOutputStream out;
private static ConsoleOutputStream err;

private static synchronized void init(SimpleAttributeSet outStyle, PrintStream outStream, SimpleAttributeSet errStyle, PrintStream errStream) {
if (out != null) {
return;
}

out = new ConsoleOutputStream(outStyle, outStream);
System.setOut(new PrintStream(out, true));
public static synchronized void setCurrentEditorConsole(EditorConsole console) {
if (out == null) {
out = new ConsoleOutputStream(console.stdOutStyle, System.out);
System.setOut(new PrintStream(out, true));

err = new ConsoleOutputStream(errStyle, errStream);
System.setErr(new PrintStream(err, true));
}
err = new ConsoleOutputStream(console.stdErrStyle, System.err);
System.setErr(new PrintStream(err, true));
}

public static void setCurrentEditorConsole(EditorConsole console) {
out.setCurrentEditorConsole(console);
err.setCurrentEditorConsole(console);
}
Expand Down Expand Up @@ -109,8 +105,6 @@ public EditorConsole(Base base) {
setPreferredSize(new Dimension(100, (height * lines)));
setMinimumSize(new Dimension(100, (height * lines)));

EditorConsole.init(stdOutStyle, System.out, stdErrStyle, System.err);

// Add font size adjustment listeners.
if (base != null)
base.addEditorFontResizeListeners(consoleTextPane);
Expand All @@ -131,8 +125,10 @@ public void applyPreferences() {
// Re-insert console text with the new preferences if there were changes.
// This assumes that the document has single-child paragraphs (default).
if (!stdOutStyle.isEqual(stdOutStyleOld) || !stdErrStyle.isEqual(stdOutStyleOld)) {
out.setAttibutes(stdOutStyle);
err.setAttibutes(stdErrStyle);
if (out != null)
out.setAttibutes(stdOutStyle);
if (err != null)
err.setAttibutes(stdErrStyle);

int start;
for (int end = document.getLength() - 1; end >= 0; end = start - 1) {
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.