diff --git a/app/src/processing/app/EditorStatus.java b/app/src/processing/app/EditorStatus.java index 57b7fba0f..fbcd3fdb1 100644 --- a/app/src/processing/app/EditorStatus.java +++ b/app/src/processing/app/EditorStatus.java @@ -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); } diff --git a/app/src/processing/app/syntax/JEditTextArea.java b/app/src/processing/app/syntax/JEditTextArea.java index fae0698cc..924eeb7a9 100644 --- a/app/src/processing/app/syntax/JEditTextArea.java +++ b/app/src/processing/app/syntax/JEditTextArea.java @@ -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; diff --git a/app/src/processing/app/tools/DiscourseFormat.java b/app/src/processing/app/tools/DiscourseFormat.java index 097d7ee2c..5494a9ca3 100644 --- a/app/src/processing/app/tools/DiscourseFormat.java +++ b/app/src/processing/app/tools/DiscourseFormat.java @@ -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 ") + diff --git a/build/shared/examples/02.Digital/Debounce/Debounce.ino b/build/shared/examples/02.Digital/Debounce/Debounce.ino index 89416b269..da3aa29d9 100644 --- a/build/shared/examples/02.Digital/Debounce/Debounce.ino +++ b/build/shared/examples/02.Digital/Debounce/Debounce.ino @@ -19,16 +19,18 @@ 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. + This example code is in the public domain. http://www.arduino.cc/en/Tutorial/Debounce */ // constants won't change. They're used here to // set pin numbers: -const int buttonPin = 2; // the number of the pushbutton pin -const int ledPin = 13; // the number of the LED pin +const int buttonPin = 2; // the number of the pushbutton pin +const int ledPin = 13; // the number of the LED pin // Variables will change: int ledState = HIGH; // the current state of the output pin @@ -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: - buttonState = reading; + + // 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: diff --git a/build/shared/examples/09.USB/Keyboard/KeyboardMessage/KeyboardMessage.ino b/build/shared/examples/09.USB/Keyboard/KeyboardMessage/KeyboardMessage.ino index 35d06c6a3..39222fdaa 100644 --- a/build/shared/examples/09.USB/Keyboard/KeyboardMessage/KeyboardMessage.ino +++ b/build/shared/examples/09.USB/Keyboard/KeyboardMessage/KeyboardMessage.ino @@ -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 diff --git a/libraries/Ethernet/examples/WebServer/WebServer.ino b/libraries/Ethernet/examples/WebServer/WebServer.ino index 0573f059d..5e5d67afa 100644 --- a/libraries/Ethernet/examples/WebServer/WebServer.ino +++ b/libraries/Ethernet/examples/WebServer/WebServer.ino @@ -22,7 +22,7 @@ // The IP address will be dependent on your local network: byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; -IPAddress ip(192,168,1, 177); +IPAddress ip(192,168,1,177); // Initialize the Ethernet server library // with the IP address and port you want to use @@ -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(""); client.println(""); - // add a meta refresh tag, so the browser pulls again every 5 seconds: - client.println(""); // output the value of each analog input pin for (int analogChannel = 0; analogChannel < 6; analogChannel++) { int sensorReading = analogRead(analogChannel); diff --git a/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino b/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino index ef97dae88..adf93a2c1 100644 --- a/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino +++ b/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino @@ -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: @@ -68,4 +68,4 @@ int digitalPotWrite(int address, int value) { SPI.transfer(value); // take the SS pin high to de-select the chip: digitalWrite(slaveSelectPin,HIGH); -} \ No newline at end of file +} diff --git a/libraries/WiFi/examples/WiFiWebServer/WiFiWebServer.ino b/libraries/WiFi/examples/WiFiWebServer/WiFiWebServer.ino index 7d7a24713..de861e880 100644 --- a/libraries/WiFi/examples/WiFiWebServer/WiFiWebServer.ino +++ b/libraries/WiFi/examples/WiFiWebServer/WiFiWebServer.ino @@ -22,7 +22,7 @@ #include -char ssid[] = "yourNetwork"; // your network SSID (name) +char ssid[] = "yourNetwork"; // your network SSID (name) char pass[] = "secretPassword"; // your network password int keyIndex = 0; // your network key Index number (needed only for WEP) @@ -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(""); client.println(""); - // add a meta refresh tag, so the browser pulls again every 5 seconds: - client.println(""); // output the value of each analog input pin for (int analogChannel = 0; analogChannel < 6; analogChannel++) { int sensorReading = analogRead(analogChannel); @@ -108,9 +107,10 @@ void loop() { } // give the web browser time to receive the data delay(1); - // close the connection: - client.stop(); - Serial.println("client disonnected"); + + // close the connection: + client.stop(); + Serial.println("client disonnected"); } }