mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-30 19:52:13 +01:00
Saving and restoring location of the serial monitor.
This commit is contained in:
parent
b3c92d834f
commit
1cac73c254
@ -788,6 +788,7 @@ public class Base {
|
|||||||
|
|
||||||
// This will store the sketch count as zero
|
// This will store the sketch count as zero
|
||||||
editors.remove(editor);
|
editors.remove(editor);
|
||||||
|
Editor.serialMonitor.closeSerialPort();
|
||||||
storeSketches();
|
storeSketches();
|
||||||
|
|
||||||
// Save out the current prefs state
|
// Save out the current prefs state
|
||||||
@ -825,6 +826,7 @@ public class Base {
|
|||||||
// If quit is canceled, this will be replaced anyway
|
// If quit is canceled, this will be replaced anyway
|
||||||
// by a later handleQuit() that is not canceled.
|
// by a later handleQuit() that is not canceled.
|
||||||
storeSketches();
|
storeSketches();
|
||||||
|
Editor.serialMonitor.closeSerialPort();
|
||||||
|
|
||||||
if (handleQuitEach()) {
|
if (handleQuitEach()) {
|
||||||
// make sure running sketches close before quitting
|
// make sure running sketches close before quitting
|
||||||
|
@ -2341,10 +2341,10 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
if (uploading) return;
|
if (uploading) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
serialMonitor.openSerialPort();
|
serialMonitor.openSerialPort();
|
||||||
serialMonitor.setVisible(true);
|
serialMonitor.setVisible(true);
|
||||||
} catch (SerialException e) {
|
} catch (SerialException e) {
|
||||||
statusError(e);
|
statusError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
package processing.app;
|
package processing.app;
|
||||||
|
|
||||||
import processing.app.debug.MessageConsumer;
|
import processing.app.debug.MessageConsumer;
|
||||||
|
import processing.core.*;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
@ -127,7 +128,7 @@ public class SerialMonitor extends JFrame implements MessageConsumer {
|
|||||||
Preferences.set("serial.debug_rate", rateString);
|
Preferences.set("serial.debug_rate", rateString);
|
||||||
closeSerialPort();
|
closeSerialPort();
|
||||||
try {
|
try {
|
||||||
openSerialPort();
|
openSerialPort();
|
||||||
} catch (SerialException e) {
|
} catch (SerialException e) {
|
||||||
System.err.println(e);
|
System.err.println(e);
|
||||||
}
|
}
|
||||||
@ -144,8 +145,40 @@ public class SerialMonitor extends JFrame implements MessageConsumer {
|
|||||||
getContentPane().add(pane, BorderLayout.SOUTH);
|
getContentPane().add(pane, BorderLayout.SOUTH);
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
|
|
||||||
|
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
|
if (Preferences.get("last.screen.height") != null) {
|
||||||
|
// if screen size has changed, the window coordinates no longer
|
||||||
|
// make sense, so don't use them unless they're identical
|
||||||
|
int screenW = Preferences.getInteger("last.screen.width");
|
||||||
|
int screenH = Preferences.getInteger("last.screen.height");
|
||||||
|
if ((screen.width == screenW) && (screen.height == screenH)) {
|
||||||
|
String locationStr = Preferences.get("last.serial.location");
|
||||||
|
if (locationStr != null) {
|
||||||
|
int[] location = PApplet.parseInt(PApplet.split(locationStr, ','));
|
||||||
|
setPlacement(location);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setPlacement(int[] location) {
|
||||||
|
setBounds(location[0], location[1], location[2], location[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int[] getPlacement() {
|
||||||
|
int[] location = new int[4];
|
||||||
|
|
||||||
|
// Get the dimensions of the Frame
|
||||||
|
Rectangle bounds = getBounds();
|
||||||
|
location[0] = bounds.x;
|
||||||
|
location[1] = bounds.y;
|
||||||
|
location[2] = bounds.width;
|
||||||
|
location[3] = bounds.height;
|
||||||
|
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
private void send(String s) {
|
private void send(String s) {
|
||||||
if (serial != null) {
|
if (serial != null) {
|
||||||
switch (lineEndings.getSelectedIndex()) {
|
switch (lineEndings.getSelectedIndex()) {
|
||||||
@ -166,6 +199,9 @@ public class SerialMonitor extends JFrame implements MessageConsumer {
|
|||||||
|
|
||||||
public void closeSerialPort() {
|
public void closeSerialPort() {
|
||||||
if (serial != null) {
|
if (serial != null) {
|
||||||
|
int[] location = getPlacement();
|
||||||
|
String locationStr = PApplet.join(PApplet.str(location), ",");
|
||||||
|
Preferences.set("last.serial.location", locationStr);
|
||||||
textArea.setText("");
|
textArea.setText("");
|
||||||
serial.dispose();
|
serial.dispose();
|
||||||
serial = null;
|
serial = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user