Go Down

Topic: Pressing enter within the serial monitor edit box (Read 729 times) previous topic - next topic


Aug 09, 2008, 12:37 pm Last Edit: Aug 09, 2008, 12:52 pm by grapelabs Reason: 1
Hi everyone,  

in a past version of the Arduino IDE, pressing enter in the serial monitor edit box appended a newline to the string sent to the serial port. This was removed in version 0006, so that pressing enter only sends the characters entered in the edit box. I don't know the rationale behind this decision (or whether there exists another way of sending a newline), but in my case i really need to send "\r\n" to some of my boards.

So i would like to propose the following patch. It changes the behavior of the key listener, so that pressing enter alone appends "\r\n" and pressing enter+ctrl doesn't.

Code: [Select]

Index: app/EditorStatus.java
--- app/EditorStatus.java      (revision 472)
+++ app/EditorStatus.java      (working copy)
@@ -421,6 +421,10 @@
          if (c == KeyEvent.VK_ENTER) {  // accept the input
+              if ((event.getModifiersEx () & KeyEvent.CTRL_DOWN_MASK) == 0)
+              {
+                editor.serialPort.write("\r\n");
+              }

This could be enhanced even more, if the modifier key and whether to send  "\n" or "\r\n" could be specified through the preferences.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131