1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-17 06:52:18 +01:00

Merge branch 'master' of github.com:arduino/Arduino into LUFA_bootloader

This commit is contained in:
Zachary Eveland 2013-05-01 10:49:05 -04:00
commit 2c5a86e336
8 changed files with 105 additions and 21 deletions

View File

@ -26,6 +26,8 @@ package processing.app;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.datatransfer.*;
import static processing.app.I18n._;
/**
@ -68,6 +70,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
JButton okButton;
JTextField editField;
JProgressBar progressBar;
JButton copyErrorButton;
//Thread promptThread;
int response;
@ -108,6 +111,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
public void notice(String message) {
mode = NOTICE;
this.message = message;
copyErrorButton.setVisible(false);
//update();
repaint();
}
@ -120,6 +124,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
public void error(String message) {
mode = ERR;
this.message = message;
copyErrorButton.setVisible(true);
repaint();
}
@ -177,6 +182,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
this.message = message;
progressBar.setIndeterminate(false);
progressBar.setVisible(true);
copyErrorButton.setVisible(false);
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
repaint();
}
@ -189,6 +195,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
progressBar.setIndeterminate(true);
progressBar.setValue(50);
progressBar.setVisible(true);
copyErrorButton.setVisible(false);
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
repaint();
}
@ -207,6 +214,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
if (Preferences.getBoolean("editor.beep.compile")) {
Toolkit.getDefaultToolkit().beep();
}
if (progressBar == null) return;
progressBar.setVisible(false);
progressBar.setValue(0);
setCursor(null);
@ -216,6 +224,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
public void progressUpdate(int value)
{
if (progressBar == null) return;
progressBar.setValue(value);
repaint();
}
@ -438,6 +447,29 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
add(progressBar);
progressBar.setVisible(false);
copyErrorButton = new JButton(_("Copy To Clipboard"));
add(copyErrorButton);
//copyErrorButton.setVisible(true);
copyErrorButton.setVisible(false);
System.out.println("create copyErrorButton");
copyErrorButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String message="";
if ((Preferences.getBoolean("build.verbose")) == false) {
message = " " + _("This report would have more information with") + "\n";
message += " \"" + _("Show verbose output during compilation") + "\"\n";
message += " " + _("enabled in File > Preferences.") + "\n";
}
message += _("Arduino: ") + Base.VERSION_NAME + " (" + System.getProperty("os.name") + "), ";
message += _("Board: ") + "\"" + Base.getBoardPreferences().get("name") + "\"\n";
message += editor.console.consoleTextPane.getText().trim();
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection data = new StringSelection(message);
clipboard.setContents(data, null);
Clipboard unixclipboard = Toolkit.getDefaultToolkit().getSystemSelection();
if (unixclipboard != null) unixclipboard.setContents(data, null);
}
});
}
}
@ -470,6 +502,10 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
editField.setBounds(yesLeft - Preferences.BUTTON_WIDTH, editTop,
editWidth, editHeight);
progressBar.setBounds(noLeft, editTop, editWidth, editHeight);
Dimension copyErrorButtonSize = copyErrorButton.getPreferredSize();
copyErrorButton.setLocation(sizeW - copyErrorButtonSize.width - 5, top);
copyErrorButton.setSize(copyErrorButtonSize.width, Preferences.BUTTON_HEIGHT);
}

View File

@ -1187,6 +1187,16 @@ public class JEditTextArea extends JComponent
selectionEndLine = newEndLine;
biasLeft = newBias;
if (newStart != newEnd) {
Clipboard unixclipboard = getToolkit().getSystemSelection();
if (unixclipboard != null) {
String selection = getSelectedText();
if (selection != null) {
unixclipboard.setContents(new StringSelection(selection), null);
}
}
}
fireCaretEvent();
}
@ -1649,7 +1659,11 @@ public class JEditTextArea extends JComponent
for(int i = 0; i < repeatCount; i++)
buf.append(selection);
clipboard.setContents(new StringSelection(buf.toString()),null);
Transferable t = new StringSelection(buf.toString());
clipboard.setContents(t, null);
Clipboard unixclipboard = getToolkit().getSystemSelection();
if (unixclipboard != null) unixclipboard.setContents(t, null);
}
}
@ -2206,6 +2220,25 @@ public class JEditTextArea extends JComponent
return;
}
// on Linux, middle button pastes selected text
if ((evt.getModifiers() & InputEvent.BUTTON2_MASK) != 0) {
Clipboard unixclipboard = getToolkit().getSystemSelection();
if (unixclipboard != null) {
Transferable t = unixclipboard.getContents(null);
if (t != null && t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
try {
String s = (String)t.getTransferData(DataFlavor.stringFlavor);
s = s.replace('\u00A0', ' ');
if (editable) setSelectedText(s);
} catch (Exception e) {
System.err.println(e);
e.printStackTrace();
}
}
return;
}
}
int line = yToLine(evt.getY());
int offset = xToOffset(line,evt.getX());
int dot = getLineStartOffset(line) + offset;

View File

@ -108,6 +108,8 @@ public class DiscourseFormat {
// i don't care about ownership
}
});
Clipboard unixclipboard = Toolkit.getDefaultToolkit().getSystemSelection();
if (unixclipboard != null) unixclipboard.setContents(formatted, null);
editor.statusNotice("Code formatted for " +
(html ? "HTML" : "the Arduino forum ") +

View File

@ -19,6 +19,8 @@
by David A. Mellis
modified 30 Aug 2011
by Limor Fried
modified 28 Dec 2012
by Mike Walters
This example code is in the public domain.
@ -43,6 +45,9 @@ long debounceDelay = 50; // the debounce time; increase if the output flicker
void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
// set initial LED state
digitalWrite(ledPin, ledState);
}
void loop() {
@ -62,11 +67,20 @@ void loop() {
if ((millis() - lastDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer
// than the debounce delay, so take it as the actual current state:
// if the button state has changed:
if (reading != buttonState) {
buttonState = reading;
// only toggle the LED if the new button state is HIGH
if (buttonState == HIGH) {
ledState = !ledState;
}
}
}
// set the LED using the state of the button:
digitalWrite(ledPin, buttonState);
// set the LED:
digitalWrite(ledPin, ledState);
// save the reading. Next time through the loop,
// it'll be the lastButtonState:

View File

@ -18,7 +18,7 @@
http://www.arduino.cc/en/Tutorial/KeyboardButton
*/
const int buttonPin = 2; // input pin for pushbutton
const int buttonPin = 4; // input pin for pushbutton
int previousButtonState = HIGH; // for checking the state of a pushButton
int counter = 0; // button push counter

View File

@ -63,12 +63,11 @@ void loop() {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 5 sec
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");
// add a meta refresh tag, so the browser pulls again every 5 seconds:
client.println("<meta http-equiv=\"refresh\" content=\"5\">");
// output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
int sensorReading = analogRead(analogChannel);

View File

@ -60,7 +60,7 @@ void loop() {
}
int digitalPotWrite(int address, int value) {
void digitalPotWrite(int address, int value) {
// take the SS pin low to select the chip:
digitalWrite(slaveSelectPin,LOW);
// send in the address and value via SPI:

View File

@ -78,12 +78,11 @@ void loop() {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 5 sec
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");
// add a meta refresh tag, so the browser pulls again every 5 seconds:
client.println("<meta http-equiv=\"refresh\" content=\"5\">");
// output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
int sensorReading = analogRead(analogChannel);
@ -108,6 +107,7 @@ void loop() {
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disonnected");