Pages: [1]   Go Down
Author Topic: Pressing enter within the serial monitor edit box  (Read 546 times)
0 Members and 1 Guest are viewing this topic.
Dortmund, NRW, Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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
             editor.serialPort.write(serialField.getText());
+              if ((event.getModifiersEx () & KeyEvent.CTRL_DOWN_MASK) == 0)
+              {
+                editor.serialPort.write("\r\n");
+              }
             event.consume();
             serialField.setText("");
           }
This could be enhanced even more, if the modifier key and whether to send  "\n" or "\r\n" could be specified through the preferences.
« Last Edit: August 09, 2008, 05:52:34 am by grapelabs » Logged

Pages: [1]   Go Up
Jump to: