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

Sign up
Appearance settings

Commit e4a7ac1

Browse files
Merge branch 'master' of https://github.com/arduino/Arduino into serial-monitor-copy-btn
2 parents 6dbc950 + 74f93fe commit e4a7ac1

File tree

73 files changed

+1745
-1261
lines changed

Some content is hidden

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

73 files changed

+1745
-1261
lines changed

‎app/.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<classpathentry kind="lib" path="lib/slf4j-api-1.7.22.jar"/>
4242
<classpathentry kind="lib" path="lib/slf4j-simple-1.7.22.jar"/>
4343
<classpathentry kind="lib" path="lib/jsch-0.1.50.jar"/>
44-
<classpathentry kind="lib" path="lib/jssc-2.8.0-arduino2.jar"/>
44+
<classpathentry kind="lib" path="lib/jssc-2.8.0-arduino3.jar"/>
4545
<classpathentry kind="lib" path="lib/rsyntaxtextarea-3.0.3-SNAPSHOT.jar"/>
4646
<classpathentry kind="lib" path="lib/xml-apis-1.3.04.jar"/>
4747
<classpathentry kind="lib" path="lib/xml-apis-ext-1.3.04.jar"/>
160 KB
Binary file not shown.

‎app/src/cc/arduino/contributions/ui/FilterJTextField.java

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,18 @@ public class FilterJTextField extends JTextField {
4141
private final String filterHint;
4242

4343
private boolean showingHint;
44+
private Timer timer;
4445

4546
public FilterJTextField(String hint) {
4647
super(hint);
4748
filterHint = hint;
4849

4950
showingHint = true;
5051
updateStyle();
52+
timer = new Timer(1000, e -> {
53+
applyFilter();
54+
timer.stop();
55+
});
5156

5257
addFocusListener(new FocusListener() {
5358
public void focusLost(FocusEvent focusEvent) {
@@ -68,33 +73,40 @@ public void focusGained(FocusEvent focusEvent) {
6873

6974
getDocument().addDocumentListener(new DocumentListener() {
7075
public void removeUpdate(DocumentEvent e) {
71-
applyFilter();
76+
spawnTimer();
7277
}
7378

7479
public void insertUpdate(DocumentEvent e) {
75-
applyFilter();
80+
spawnTimer();
7681
}
7782

7883
public void changedUpdate(DocumentEvent e) {
79-
applyFilter();
84+
85+
}
86+
});
87+
88+
addActionListener(e -> {
89+
if (timer.isRunning()) {
90+
timer.stop();
8091
}
92+
applyFilter();
8193
});
8294
}
8395

84-
private String lastFilter = "";
96+
private void spawnTimer() {
97+
if (timer.isRunning()) {
98+
timer.stop();
99+
}
100+
timer.start();
101+
}
85102

86-
private void applyFilter() {
103+
public void applyFilter() {
87104
String filter = showingHint ? "" : getText();
88105
filter = filter.toLowerCase();
89106

90107
// Replace anything but 0-9, a-z, or : with a space
91108
filter = filter.replaceAll("[^\\x30-\\x39^\\x61-\\x7a^\\x3a]", " ");
92109

93-
// Fire event only if the filter is changed
94-
if (filter.equals(lastFilter))
95-
return;
96-
97-
lastFilter = filter;
98110
onFilter(filter.split(" "));
99111
}
100112

‎app/src/cc/arduino/contributions/ui/InstallerJDialog.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ public void setFilterText(String filterText) {
320320
listener.focusGained(new FocusEvent(filterField, FocusEvent.FOCUS_GAINED));
321321
}
322322
filterField.setText(filterText);
323+
filterField.applyFilter();
323324
}
324325

325326
public void selectDropdownItemByClassName(String dropdownItem) {

‎app/src/processing/app/Base.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ public Base(String[] args) throws Exception {
267267
splash.splashText(tr("Initializing packages..."));
268268
BaseNoGui.initPackages();
269269

270+
parser.getUploadPort().ifPresent(BaseNoGui::selectSerialPort);
271+
270272
splash.splashText(tr("Preparing boards..."));
271273

272274
if (!isCommandLine()) {

‎app/src/processing/app/Editor.java

Lines changed: 63 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import java.util.ArrayList;
5353
import java.util.Arrays;
5454
import java.util.Collections;
55-
import java.util.Comparator;
5655
import java.util.Enumeration;
5756
import java.util.HashMap;
5857
import java.util.LinkedList;
@@ -82,6 +81,8 @@
8281
import javax.swing.event.MenuListener;
8382
import javax.swing.text.BadLocationException;
8483

84+
import org.fife.ui.rsyntaxtextarea.folding.FoldManager;
85+
8586
import com.jcraft.jsch.JSchException;
8687

8788
import cc.arduino.CompilerProgressListener;
@@ -94,6 +95,7 @@
9495
import cc.arduino.view.findreplace.FindReplace;
9596
import jssc.SerialPortException;
9697
import processing.app.debug.RunnerException;
98+
import processing.app.debug.TargetBoard;
9799
import processing.app.forms.PasswordAuthorizationDialog;
98100
import processing.app.helpers.DocumentTextChangeListener;
99101
import processing.app.helpers.Keys;
@@ -147,9 +149,6 @@ public boolean test(SketchController controller) {
147149
}
148150
}
149151

150-
private final static List<String> BOARD_PROTOCOLS_ORDER = Arrays.asList("serial", "network");
151-
private final static List<String> BOARD_PROTOCOLS_ORDER_TRANSLATIONS = Arrays.asList(tr("Serial ports"), tr("Network ports"));
152-
153152
final Base base;
154153

155154
// otherwise, if the window is resized with the message label
@@ -1041,22 +1040,30 @@ class BoardPortJCheckBoxMenuItem extends JCheckBoxMenuItem {
10411040
private BoardPort port;
10421041

10431042
public BoardPortJCheckBoxMenuItem(BoardPort port) {
1044-
super(port.getLabel());
1043+
super();
1044+
this.port = port;
1045+
setText(toString());
10451046
addActionListener(e -> {
10461047
selectSerialPort(port.getAddress());
10471048
base.onBoardOrPortChange();
10481049
});
1049-
this.port = port;
10501050
}
10511051

10521052
@Override
10531053
public String toString() {
10541054
// This is required for serialPrompt()
1055-
return port.getLabel();
1055+
String label = port.getLabel();
1056+
if (port.getBoardName() != null && !port.getBoardName().isEmpty()) {
1057+
label += " (" + port.getBoardName() + ")";
1058+
}
1059+
return label;
10561060
}
10571061
}
10581062

10591063
private void populatePortMenu() {
1064+
final List<String> PROTOCOLS_ORDER = Arrays.asList("serial", "network");
1065+
final List<String> PROTOCOLS_LABELS = Arrays.asList(tr("Serial ports"), tr("Network ports"));
1066+
10601067
portMenu.removeAll();
10611068

10621069
String selectedPort = PreferencesData.get("serial.port");
@@ -1065,31 +1072,43 @@ private void populatePortMenu() {
10651072

10661073
ports = platform.filterPorts(ports, PreferencesData.getBoolean("serial.ports.showall"));
10671074

1068-
Collections.sort(ports, new Comparator<BoardPort>() {
1069-
@Override
1070-
public int compare(BoardPort o1, BoardPort o2) {
1071-
return (BOARD_PROTOCOLS_ORDER.indexOf(o1.getProtocol()) - BOARD_PROTOCOLS_ORDER.indexOf(o2.getProtocol())) * 10 +
1072-
o1.getAddress().compareTo(o2.getAddress());
1073-
}
1075+
ports.stream() //
1076+
.filter(port -> port.getProtocolLabel() == null || port.getProtocolLabel().isEmpty())
1077+
.forEach(port -> {
1078+
int labelIdx = PROTOCOLS_ORDER.indexOf(port.getProtocol());
1079+
if (labelIdx != -1) {
1080+
port.setProtocolLabel(PROTOCOLS_LABELS.get(labelIdx));
1081+
} else {
1082+
port.setProtocolLabel(port.getProtocol());
1083+
}
1084+
});
1085+
1086+
Collections.sort(ports, (port1, port2) -> {
1087+
String pr1 = port1.getProtocol();
1088+
String pr2 = port2.getProtocol();
1089+
int prIdx1 = PROTOCOLS_ORDER.contains(pr1) ? PROTOCOLS_ORDER.indexOf(pr1) : 999;
1090+
int prIdx2 = PROTOCOLS_ORDER.contains(pr2) ? PROTOCOLS_ORDER.indexOf(pr2) : 999;
1091+
int r = prIdx1 - prIdx2;
1092+
if (r != 0)
1093+
return r;
1094+
r = port1.getProtocolLabel().compareTo(port2.getProtocolLabel());
1095+
if (r != 0)
1096+
return r;
1097+
return port1.getAddress().compareTo(port2.getAddress());
10741098
});
10751099

1076-
String lastProtocol = null;
1077-
String lastProtocolTranslated;
1100+
String lastProtocol = "";
1101+
String lastProtocolLabel = "";
10781102
for (BoardPort port : ports) {
1079-
if (lastProtocol == null|| !port.getProtocol().equals(lastProtocol)) {
1080-
if (lastProtocol != null) {
1103+
if (!port.getProtocol().equals(lastProtocol) || !port.getProtocolLabel().equals(lastProtocolLabel)) {
1104+
if (!lastProtocol.isEmpty()) {
10811105
portMenu.addSeparator();
10821106
}
10831107
lastProtocol = port.getProtocol();
1084-
1085-
if (BOARD_PROTOCOLS_ORDER.indexOf(port.getProtocol()) != -1) {
1086-
lastProtocolTranslated = BOARD_PROTOCOLS_ORDER_TRANSLATIONS.get(BOARD_PROTOCOLS_ORDER.indexOf(port.getProtocol()));
1087-
} else {
1088-
lastProtocolTranslated = port.getProtocol();
1089-
}
1090-
JMenuItem lastProtocolMenuItem = new JMenuItem(tr(lastProtocolTranslated));
1091-
lastProtocolMenuItem.setEnabled(false);
1092-
portMenu.add(lastProtocolMenuItem);
1108+
lastProtocolLabel = port.getProtocolLabel();
1109+
JMenuItem item = new JMenuItem(tr(lastProtocolLabel));
1110+
item.setEnabled(false);
1111+
portMenu.add(item);
10931112
}
10941113
String address = port.getAddress();
10951114

@@ -1648,8 +1667,17 @@ public void removeAllLineHighlights() {
16481667
}
16491668

16501669
public void addLineHighlight(int line) throws BadLocationException {
1651-
getCurrentTab().getTextArea().addLineHighlight(line, new Color(1, 0, 0, 0.2f));
1652-
getCurrentTab().getTextArea().setCaretPosition(getCurrentTab().getTextArea().getLineStartOffset(line));
1670+
SketchTextArea textArea = getCurrentTab().getTextArea();
1671+
FoldManager foldManager = textArea.getFoldManager();
1672+
if (foldManager.isLineHidden(line)) {
1673+
for (int i = 0; i < foldManager.getFoldCount(); i++) {
1674+
if (foldManager.getFold(i).containsLine(line)) {
1675+
foldManager.getFold(i).setCollapsed(false);
1676+
}
1677+
}
1678+
}
1679+
textArea.addLineHighlight(line, new Color(1, 0, 0, 0.2f));
1680+
textArea.setCaretPosition(textArea.getLineStartOffset(line));
16531681
}
16541682

16551683

@@ -2392,9 +2420,9 @@ private void handleBoardInfo() {
23922420
for (BoardPort port : ports) {
23932421
if (port.getAddress().equals(selectedPort)) {
23942422
label = port.getBoardName();
2395-
vid = port.getVID();
2396-
pid = port.getPID();
2397-
iserial = port.getISerial();
2423+
vid = port.getPrefs().get("vid");
2424+
pid = port.getPrefs().get("pid");
2425+
iserial = port.getPrefs().get("iserial");
23982426
protocol = port.getProtocol();
23992427
found = true;
24002428
break;
@@ -2564,12 +2592,12 @@ private void statusEmpty() {
25642592
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
25652593

25662594
protected void onBoardOrPortChange() {
2567-
Map<String, String> boardPreferences= BaseNoGui.getBoardPreferences();
2568-
if (boardPreferences != null)
2569-
lineStatus.setBoardName(boardPreferences.get("name"));
2595+
TargetBoardboard= BaseNoGui.getTargetBoard();
2596+
if (board != null)
2597+
lineStatus.setBoardName(board.getName());
25702598
else
25712599
lineStatus.setBoardName("-");
2572-
lineStatus.setSerialPort(PreferencesData.get("serial.port"));
2600+
lineStatus.setPort(PreferencesData.get("serial.port"));
25732601
lineStatus.repaint();
25742602
}
25752603

‎app/src/processing/app/EditorLineStatus.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ public class EditorLineStatus extends JComponent {
5151

5252
String text = "";
5353
String name = "";
54-
String serialport = "";
55-
String serialnumber = "";
54+
String port = "";
5655

5756
public EditorLineStatus() {
5857
background = Theme.getColor("linestatus.bgcolor");
@@ -92,13 +91,13 @@ public void set(int newStart, int newStop) {
9291

9392
public void paintComponent(Graphics graphics) {
9493
Graphics2D g = Theme.setupGraphics2D(graphics);
95-
if (name.isEmpty() && serialport.isEmpty()) {
94+
if (name.isEmpty() && port.isEmpty()) {
9695
PreferencesMap boardPreferences = BaseNoGui.getBoardPreferences();
9796
if (boardPreferences != null)
9897
setBoardName(boardPreferences.get("name"));
9998
else
10099
setBoardName("-");
101-
setSerialPort(PreferencesData.get("serial.port"));
100+
setPort(PreferencesData.get("serial.port"));
102101
}
103102
g.setColor(background);
104103
Dimension size = getSize();
@@ -112,8 +111,8 @@ public void paintComponent(Graphics graphics) {
112111
g.setColor(messageForeground);
113112

114113
String statusText;
115-
if (serialport != null && !serialport.isEmpty()) {
116-
statusText = I18n.format(tr("{0} on {1}"), name, serialport);
114+
if (port != null && !port.isEmpty()) {
115+
statusText = I18n.format(tr("{0} on {1}"), name, port);
117116
} else {
118117
statusText = name;
119118
}
@@ -132,12 +131,8 @@ public void setBoardName(String name) {
132131
this.name = name;
133132
}
134133

135-
public void setSerialPort(String serialport) {
136-
this.serialport = serialport;
137-
}
138-
139-
public void setSerialNumber(String serialnumber) {
140-
this.serialnumber = serialnumber;
134+
public void setPort(String port) {
135+
this.port = port;
141136
}
142137

143138
public Dimension getPreferredSize() {

‎app/src/processing/app/SketchController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ private File saveSketchInTempFolder() throws IOException {
674674
FileUtils.copy(sketch.getFolder(), tempFolder);
675675

676676
for (SketchFile file : Stream.of(sketch.getFiles()).filter(SketchFile::isModified).collect(Collectors.toList())) {
677-
Files.write(Paths.get(tempFolder.getAbsolutePath(), file.getFileName()), file.getProgram().getBytes());
677+
Files.write(Paths.get(tempFolder.getAbsolutePath(), file.getFileName()), file.getProgram().getBytes("UTF-8"));
678678
}
679679

680680
return Paths.get(tempFolder.getAbsolutePath(), sketch.getPrimaryFile().getFileName()).toFile();

‎arduino-core/.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<classpathentry kind="lib" path="lib/jmdns-3.5.3.jar"/>
99
<classpathentry kind="lib" path="lib/slf4j-api-1.7.22.jar"/>
1010
<classpathentry kind="lib" path="lib/slf4j-simple-1.7.22.jar"/>
11-
<classpathentry kind="lib" path="lib/jssc-2.8.0-arduino2.jar"/>
11+
<classpathentry kind="lib" path="lib/jssc-2.8.0-arduino3.jar"/>
1212
<classpathentry kind="lib" path="lib/jsch-0.1.50.jar"/>
1313
<classpathentry kind="lib" path="lib/commons-exec-1.1.jar"/>
1414
<classpathentry kind="lib" path="../app/lib/commons-httpclient-3.1.jar"/>
160 KB
Binary file not shown.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /