Little improvement on Serial Monitor

Playing around with the Arduino, I started missing the option to automatically send a line feed (\n) from the terminal monitor.

Since the development environment is open source, I couldn't resist adding it in. For anyone who's interested as well, here's the patch.

The patch:

--- SerialMonitor.org.java      2010-01-19 12:16:49.906250000 +0100
+++ SerialMonitor.java      2010-01-19 16:22:58.015625000 +0100
@@ -32,6 +32,7 @@
   private JTextArea textArea;
   private JTextField textField;
   private JButton sendButton;
+  private JCheckBox sendNewLine;
   private JComboBox serialRates;
   private JLabel statusLabel;
   private int serialRate;
@@ -73,18 +74,26 @@
     textField.addActionListener(new ActionListener() {
       public void actionPerformed(ActionEvent e) {
         send(textField.getText());
+        if(sendNewLine.isSelected()) send("\n");
         textField.setText("");
       }});
 
+    pane.add(textField, BorderLayout.CENTER);
+
+    JPanel sendPane = new JPanel(new FlowLayout());
+
     sendButton = new JButton("Send");
     sendButton.addActionListener(new ActionListener() {
       public void actionPerformed(ActionEvent e) {
         send(textField.getText());
+        if(sendNewLine.isSelected()) send("\n");
         textField.setText("");
       }});
 
-    pane.add(textField, BorderLayout.CENTER);
-    pane.add(sendButton, BorderLayout.EAST);
+    sendNewLine = new JCheckBox("Newline");
+    sendPane.add(sendButton);
+      sendPane.add(sendNewLine);
+    pane.add(sendPane, BorderLayout.EAST);
 
     getContentPane().add(pane, BorderLayout.NORTH);

As you can see I've added the checkbox in a new panel. This panel has a FlowLayout. It contains the Send button too and is located in the East border, where the Send button used to be, in the BorderLayout panel.

That's pretty interesting. Thank you.

On the issue list I saw someone asking for the ability to send special characters using escape sequences, like \n.

Modifying the SerilMonitor code a little bit more, I have implemented this request. The patch can be found in my reply on the issue list:
http://code.google.com/p/arduino/issues/detail?id=119#c1

Oh, great. Thanks a lot, I was just gonna smash my head with the wall lol

Could you please tell us how to install this patch though?

Thanks

Hi VAM,

To install the patch you will have to build Arduino from source yourself.

You will need a subversion client (TortoiseSVN, Workbench for Subversion, etc)
Then using this client you can get the sources from the trunk (more info: Google Code Archive - Long-term storage for Google Code Project Hosting.)
Most subversion clients also include a tool to apply .patch files.
When you're using TortoiseSVN you'll only have to double click the .patch file.
How to build the Arduino IDE is explained here: Google Code Archive - Long-term storage for Google Code Project Hosting.

Maybe you can upload the modified jar files :slight_smile:

Ok, I'll upload my pde.jar file.
Though I don't know what will break if you replace it... haven't tested it myself.

Please share any results.
My compiled pde.jar can be downloaded from
http://www.xs4all.nl/~hvmarle/arduino/2010013001_pde.jar

There are a few extra changes in the jar

Thanks, I guess that this pde.jar is from 0017 not 0018 right?

It's build on the most recent subersion version, which was at the time identical to 0018 I think. Maybe a few extra additions on top of 0018.