Skip to content

Commit 0f41b96

Browse files
committed
Merge remote-tracking branch 'arduino/ide-1.5.x' into HEAD
2 parents 68fe402 + 7f7637c commit 0f41b96

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+608
-1382
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ hardware/arduino/bootloaders/caterina_LUFA/Caterina.elf
1414
hardware/arduino/bootloaders/caterina_LUFA/Caterina.eep
1515
hardware/arduino/bootloaders/caterina_LUFA/.dep/
1616
build/windows/work/
17+
build/windows/arduino-*.zip
18+
build/windows/dist/gcc-*.tar.gz
19+
build/macosx/arduino-*.zip
20+
build/macosx/dist/gcc-*.tar.gz
1721
build/linux/work/
1822
build/linux/dist/*.tar.gz
1923
build/linux/*.tgz

app/lib/RXTXcomm.jar

3.54 KB
Binary file not shown.

app/src/processing/app/Base.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
* files and images, etc) that comes from that.
5151
*/
5252
public class Base {
53-
public static final int REVISION = 152;
53+
public static final int REVISION = 153;
5454
/** This might be replaced by main() if there's a lib/version.txt file. */
55-
static String VERSION_NAME = "0152";
55+
static String VERSION_NAME = "0153";
5656
/** Set true if this a proper release rather than a numbered revision. */
5757
static public boolean RELEASE = false;
5858

@@ -652,7 +652,10 @@ protected String createNewUntitled() throws IOException {
652652

653653
// Make an empty pde file
654654
File newbieFile = new File(newbieDir, newbieName + ".ino");
655-
new FileOutputStream(newbieFile); // create the file
655+
if (!newbieFile.createNewFile()) {
656+
throw new IOException();
657+
}
658+
FileUtils.copyFile(new File(getContentFile("examples"), "01.Basics" + File.separator + "BareMinimum" + File.separator + "BareMinimum.ino"), newbieFile);
656659
return newbieFile.getAbsolutePath();
657660
}
658661

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package processing.app;
2+
3+
import processing.app.syntax.JEditTextArea;
4+
5+
import javax.swing.undo.CannotRedoException;
6+
import javax.swing.undo.CannotUndoException;
7+
import javax.swing.undo.UndoableEdit;
8+
9+
public class CaretAwareUndoableEdit implements UndoableEdit {
10+
11+
private final UndoableEdit undoableEdit;
12+
private final int caretPosition;
13+
14+
public CaretAwareUndoableEdit(UndoableEdit undoableEdit, JEditTextArea textArea) {
15+
this.undoableEdit = undoableEdit;
16+
this.caretPosition = textArea.getCaretPosition();
17+
}
18+
19+
@Override
20+
public void undo() throws CannotUndoException {
21+
undoableEdit.undo();
22+
}
23+
24+
@Override
25+
public boolean canUndo() {
26+
return undoableEdit.canUndo();
27+
}
28+
29+
@Override
30+
public void redo() throws CannotRedoException {
31+
undoableEdit.redo();
32+
}
33+
34+
@Override
35+
public boolean canRedo() {
36+
return undoableEdit.canRedo();
37+
}
38+
39+
@Override
40+
public void die() {
41+
undoableEdit.die();
42+
}
43+
44+
@Override
45+
public boolean addEdit(UndoableEdit undoableEdit) {
46+
return this.undoableEdit.addEdit(undoableEdit);
47+
}
48+
49+
@Override
50+
public boolean replaceEdit(UndoableEdit undoableEdit) {
51+
return this.undoableEdit.replaceEdit(undoableEdit);
52+
}
53+
54+
@Override
55+
public boolean isSignificant() {
56+
return undoableEdit.isSignificant();
57+
}
58+
59+
@Override
60+
public String getPresentationName() {
61+
return undoableEdit.getPresentationName();
62+
}
63+
64+
@Override
65+
public String getUndoPresentationName() {
66+
return undoableEdit.getUndoPresentationName();
67+
}
68+
69+
@Override
70+
public String getRedoPresentationName() {
71+
return undoableEdit.getRedoPresentationName();
72+
}
73+
74+
public int getCaretPosition() {
75+
return caretPosition;
76+
}
77+
}

app/src/processing/app/Editor.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public class Editor extends JFrame implements RunnerListener {
137137
JMenuItem undoItem, redoItem;
138138
protected UndoAction undoAction;
139139
protected RedoAction redoAction;
140-
UndoManager undo;
140+
LastUndoableEditAwareUndoManager undo;
141141
// used internally, and only briefly
142142
CompoundEdit compoundEdit;
143143

@@ -476,7 +476,6 @@ protected void applyPreferences() {
476476

477477
protected void buildMenuBar() {
478478
JMenuBar menubar = new JMenuBar();
479-
menubar = new JMenuBar();
480479
menubar.add(buildFileMenu());
481480
menubar.add(buildEditMenu());
482481
menubar.add(buildSketchMenu());
@@ -1344,6 +1343,10 @@ public void actionPerformed(ActionEvent e) {
13441343
//System.out.println("Unable to undo: " + ex);
13451344
//ex.printStackTrace();
13461345
}
1346+
if (undo.getLastUndoableEdit() != null && undo.getLastUndoableEdit() instanceof CaretAwareUndoableEdit) {
1347+
CaretAwareUndoableEdit undoableEdit = (CaretAwareUndoableEdit) undo.getLastUndoableEdit();
1348+
textarea.setCaretPosition(undoableEdit.getCaretPosition() - 1);
1349+
}
13471350
updateUndoState();
13481351
redoAction.updateRedoState();
13491352
}
@@ -1383,6 +1386,10 @@ public void actionPerformed(ActionEvent e) {
13831386
//System.out.println("Unable to redo: " + ex);
13841387
//ex.printStackTrace();
13851388
}
1389+
if (undo.getLastUndoableEdit() != null && undo.getLastUndoableEdit() instanceof CaretAwareUndoableEdit) {
1390+
CaretAwareUndoableEdit undoableEdit = (CaretAwareUndoableEdit) undo.getLastUndoableEdit();
1391+
textarea.setCaretPosition(undoableEdit.getCaretPosition());
1392+
}
13861393
updateRedoState();
13871394
undoAction.updateUndoState();
13881395
}
@@ -1664,7 +1671,7 @@ public void undoableEditHappened(UndoableEditEvent e) {
16641671
compoundEdit.addEdit(e.getEdit());
16651672

16661673
} else if (undo != null) {
1667-
undo.addEdit(e.getEdit());
1674+
undo.addEdit(new CaretAwareUndoableEdit(e.getEdit(), textarea));
16681675
undoAction.updateUndoState();
16691676
redoAction.updateRedoState();
16701677
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package processing.app;
2+
3+
import javax.swing.undo.CannotRedoException;
4+
import javax.swing.undo.CannotUndoException;
5+
import javax.swing.undo.UndoManager;
6+
import javax.swing.undo.UndoableEdit;
7+
8+
public class LastUndoableEditAwareUndoManager extends UndoManager {
9+
10+
private UndoableEdit lastUndoableEdit;
11+
12+
public LastUndoableEditAwareUndoManager() {
13+
this.lastUndoableEdit = null;
14+
}
15+
16+
@Override
17+
public synchronized void undo() throws CannotUndoException {
18+
lastUndoableEdit = super.editToBeUndone();
19+
super.undo();
20+
}
21+
22+
@Override
23+
public synchronized void redo() throws CannotRedoException {
24+
lastUndoableEdit = super.editToBeRedone();
25+
super.redo();
26+
}
27+
28+
public UndoableEdit getLastUndoableEdit() {
29+
return lastUndoableEdit;
30+
}
31+
}

app/src/processing/app/Platform.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void init(Base base) {
7676
public File getSettingsFolder() throws Exception {
7777
// otherwise make a .processing directory int the user's home dir
7878
File home = new File(System.getProperty("user.home"));
79-
File dataFolder = new File(home, ".arduino");
79+
File dataFolder = new File(home, ".arduino15");
8080
return dataFolder;
8181

8282
/*

app/src/processing/app/Preferences.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,15 @@ static protected void init(String commandLinePrefs) {
302302

303303
// other things that have to be set explicitly for the defaults
304304
setColor("run.window.bgcolor", SystemColor.control);
305+
306+
fixPreferences();
307+
}
308+
309+
private static void fixPreferences() {
310+
String baud = get("serial.debug_rate");
311+
if ("14400".equals(baud) || "28800".equals(baud) || "38400".equals(baud)) {
312+
set("serial.debug_rate", "9600");
313+
}
305314
}
306315

307316

app/src/processing/app/Serial.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ public Serial(String iname, int irate,
159159
if (portId.getName().equals(iname)) {
160160
//System.out.println("looking for "+iname);
161161
port = (SerialPort)portId.open("serial madness", 2000);
162+
port.setDTR(true);
163+
port.setRTS(true);
162164
input = port.getInputStream();
163165
output = port.getOutputStream();
164166
port.setSerialPortParams(rate, databits, stopbits, parity);

app/src/processing/app/SerialMonitor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ public void actionPerformed(ActionEvent event) {
121121
lineEndings.setMaximumSize(lineEndings.getMinimumSize());
122122

123123
String[] serialRateStrings = {
124-
"300","1200","2400","4800","9600","14400",
125-
"19200","28800","38400","57600","115200"
124+
"300","1200","2400","4800","9600",
125+
"19200","57600","115200"
126126
};
127127

128128
serialRates = new JComboBox();

app/src/processing/app/SketchCode.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import java.io.*;
2828

2929
import javax.swing.text.Document;
30-
import javax.swing.undo.*;
30+
3131
import static processing.app.I18n._;
3232

3333

@@ -55,7 +55,7 @@ public class SketchCode {
5555
* Editor.undo will be set to this object when this code is the tab
5656
* that's currently the front.
5757
*/
58-
private UndoManager undo = new UndoManager();
58+
private LastUndoableEditAwareUndoManager undo = new LastUndoableEditAwareUndoManager();
5959

6060
// saved positions from last time this tab was used
6161
private int selectionStart;
@@ -221,7 +221,7 @@ public void setDocument(Document d) {
221221
}
222222

223223

224-
public UndoManager getUndo() {
224+
public LastUndoableEditAwareUndoManager getUndo() {
225225
return undo;
226226
}
227227

app/src/processing/app/debug/TargetPackage.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,22 @@
3232

3333
public class TargetPackage {
3434

35-
String name;
36-
File folder;
35+
private final String name;
3736

3837
Map<String, TargetPlatform> platforms = new HashMap<String, TargetPlatform>();
3938

40-
public TargetPackage(String _name, File _folder) {
41-
name = _name;
42-
folder = _folder;
39+
public TargetPackage(String name, File folder) {
40+
this.name = name;
4341

4442
String[] platformsList = folder.list(new OnlyDirs());
45-
for (String platformName : platformsList) {
46-
File platformFolder = new File(folder, platformName);
47-
TargetPlatform platform = new TargetPlatform(platformName, platformFolder);
48-
platforms.put(platformName, platform);
43+
if (platformsList != null) {
44+
for (String platformName : platformsList) {
45+
File platformFolder = new File(folder, platformName);
46+
if (platformFolder.exists() && platformFolder.canRead()) {
47+
TargetPlatform platform = new TargetPlatform(platformName, platformFolder);
48+
platforms.put(platformName, platform);
49+
}
50+
}
4951
}
5052
}
5153

app/src/processing/app/debug/TargetPlatform.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public TargetPlatform(String _name, File _folder) {
5555

5656
try {
5757
File boardsFile = new File(_folder, "boards.txt");
58-
if (boardsFile.exists()) {
58+
if (boardsFile.exists() && boardsFile.canRead()) {
5959
PreferencesMap boardPreferences = new PreferencesMap();
6060
boardPreferences.load(boardsFile);
6161
boards = boardPreferences.createFirstLevelMap();
@@ -69,15 +69,16 @@ public TargetPlatform(String _name, File _folder) {
6969

7070
try {
7171
File platformsFile = new File(_folder, "platform.txt");
72-
if (platformsFile.exists())
72+
if (platformsFile.exists() && platformsFile.canRead()) {
7373
preferences.load(platformsFile);
74+
}
7475
} catch (Exception e) {
7576
System.err.println("Error loading platforms from platform.txt: " + e);
7677
}
7778

7879
try {
7980
File programmersFile = new File(_folder, "programmers.txt");
80-
if (programmersFile.exists()) {
81+
if (programmersFile.exists() && programmersFile.canRead()) {
8182
PreferencesMap prefs = new PreferencesMap();
8283
prefs.load(programmersFile);
8384
programmers = prefs.createFirstLevelMap();

app/src/processing/app/helpers/FileUtils.java

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,27 @@ public static boolean isSubDirectory(File base, File child) {
3535
return false;
3636
}
3737

38+
public static void copyFile(File source, File dest) throws IOException {
39+
FileInputStream fis = null;
40+
FileOutputStream fos = null;
41+
try {
42+
fis = new FileInputStream(source);
43+
fos = new FileOutputStream(dest);
44+
byte[] buf = new byte[4096];
45+
int readBytes = -1;
46+
while ((readBytes = fis.read(buf, 0, buf.length)) != -1) {
47+
fos.write(buf, 0, readBytes);
48+
}
49+
} finally {
50+
if (fis != null) {
51+
fis.close();
52+
}
53+
if (fos != null) {
54+
fos.close();
55+
}
56+
}
57+
}
58+
3859
public static void copy(File sourceFolder, File destFolder) throws IOException {
3960
for (File file : sourceFolder.listFiles()) {
4061
File destFile = new File(destFolder, file.getName());
@@ -44,24 +65,7 @@ public static void copy(File sourceFolder, File destFolder) throws IOException {
4465
}
4566
copy(file, destFile);
4667
} else {
47-
FileInputStream fis = null;
48-
FileOutputStream fos = null;
49-
try {
50-
fis = new FileInputStream(file);
51-
fos = new FileOutputStream(destFile);
52-
byte[] buf = new byte[4096];
53-
int readBytes = -1;
54-
while ((readBytes = fis.read(buf, 0, buf.length)) != -1) {
55-
fos.write(buf, 0, readBytes);
56-
}
57-
} finally {
58-
if (fis != null) {
59-
fis.close();
60-
}
61-
if (fos != null) {
62-
fos.close();
63-
}
64-
}
68+
copyFile(file, destFile);
6569
}
6670
}
6771
}

app/src/processing/app/helpers/PreferencesMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public PreferencesMap() {
5050
* @throws FileNotFoundException
5151
* @throws IOException
5252
*/
53-
public void load(File file) throws FileNotFoundException, IOException {
53+
public void load(File file) throws IOException {
5454
load(new FileInputStream(file));
5555
}
5656

app/src/processing/app/macosx/Platform.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void init(Base base) {
8585

8686

8787
public File getSettingsFolder() throws Exception {
88-
return new File(getLibraryFolder(), "Arduino");
88+
return new File(getLibraryFolder(), "Arduino15");
8989
}
9090

9191

0 commit comments

Comments
 (0)