From 7ae377d3e99a5515cd89ddb6675ff2b84c232f3b Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 20 Jan 2020 17:04:04 +0100 Subject: [PATCH] Do not clear serial monitor when disabled for upload (@PaulStoffregen) Fix #9234 --- .../processing/app/AbstractTextMonitor.java | 25 ++++++++++++++++--- app/src/processing/app/SerialMonitor.java | 1 - 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/src/processing/app/AbstractTextMonitor.java b/app/src/processing/app/AbstractTextMonitor.java index 4e35d4e44..733bae41b 100644 --- a/app/src/processing/app/AbstractTextMonitor.java +++ b/app/src/processing/app/AbstractTextMonitor.java @@ -3,6 +3,7 @@ package processing.app; import static processing.app.I18n.tr; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.Container; import java.awt.Dimension; import java.awt.Font; @@ -170,9 +171,27 @@ public abstract class AbstractTextMonitor extends AbstractMonitor { } @Override - protected void onEnableWindow(boolean enable) - { - textArea.setEnabled(enable); + protected void onEnableWindow(boolean enable) { + Thread.dumpStack(); + System.out.println("onEnableWindow " + enable); + // never actually disable textArea, so people can + // still select & copy text, even when the port + // is closed or disconnected + textArea.setEnabled(true); + if (enable) { + // setting these to null for system default + // gives a wrong gray background on Windows + // so assume black text on white background + textArea.setForeground(Color.BLACK); + textArea.setBackground(Color.WHITE); + } else { + // In theory, UIManager.getDefaults() should + // give us the system's colors for disabled + // windows. But it doesn't seem to work. :( + textArea.setForeground(new Color(64, 64, 64)); + textArea.setBackground(new Color(238, 238, 238)); + } + textArea.invalidate(); clearButton.setEnabled(enable); scrollPane.setEnabled(enable); textField.setEnabled(enable); diff --git a/app/src/processing/app/SerialMonitor.java b/app/src/processing/app/SerialMonitor.java index acdfc9cb9..9af95d8d4 100644 --- a/app/src/processing/app/SerialMonitor.java +++ b/app/src/processing/app/SerialMonitor.java @@ -142,7 +142,6 @@ public class SerialMonitor extends AbstractTextMonitor { int[] location = getPlacement(); String locationStr = PApplet.join(PApplet.str(location), ","); PreferencesData.set("last.serial.location", locationStr); - textArea.setText(""); serial.dispose(); serial = null; }