Skip to content

Serial Monitor message history #1404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
philipmcgaw-cpi opened this issue Sep 6, 2022 · 2 comments · Fixed by #1562
Closed
3 tasks done

Serial Monitor message history #1404

philipmcgaw-cpi opened this issue Sep 6, 2022 · 2 comments · Fixed by #1562
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself topic: serial monitor Related to the Serial Monitor type: enhancement Proposed improvement

Comments

@philipmcgaw-cpi
Copy link

philipmcgaw-cpi commented Sep 6, 2022

Describe the request

In Arduino IDE 1.x, you can 'up arrow' through the recently sent commands, to send the same one a second time, or even go further back in history.

Describe the current behavior

none, this functionality is missing.

Arduino IDE version

IDE 2.0.0-rc9.3

Operating system

macOS

Operating system version

Monterey

Additional context

No response

Issue checklist

  • I searched for previous requests in the issue tracker
  • I verified the feature was still missing when using the latest nightly build
  • My request contains all necessary details
@philipmcgaw-cpi philipmcgaw-cpi added the type: enhancement Proposed improvement label Sep 6, 2022
@philipmcgaw-cpi
Copy link
Author

This issue is linked to a forum post: https://forum.arduino.cc/t/ide-2-0-0-rc9-3-serial-console-text-entry/1028868/3

@per1234 per1234 added topic: code Related to content of the project itself topic: serial monitor Related to the Serial Monitor labels Sep 6, 2022
@nmzaheer
Copy link
Contributor

nmzaheer commented Sep 9, 2022

The legacy IDE has a separate class called commandHistory that implements this functionality at CommandHistory.java

public class CommandHistory {

  private final LinkedList<String> commandHistory = new LinkedList<String>();
  private final int maxHistorySize;
  private ListIterator<String> iterator = null;

which is consumed by SerialMonitor.java as

      public void keyPressed(KeyEvent e) {
        switch (e.getKeyCode()) {

          // Select previous command.
          case KeyEvent.VK_UP:
            if (commandHistory.hasPreviousCommand()) {
              textField.setText(
                  commandHistory.getPreviousCommand(textField.getText()));
            }
            break;

          // Select next command.
          case KeyEvent.VK_DOWN:
            if (commandHistory.hasNextCommand()) {
              textField.setText(commandHistory.getNextCommand());
            }
            break;

          // Reset history location, restoring the last unexecuted command.
          case KeyEvent.VK_ESCAPE:
            textField.setText(commandHistory.resetHistoryLocation());
            break;
        }
      }
    });

Proposal

  1. I'm not sure whether Javascript has a built-in standard LinkedList implementation which means we will have to write an implementation of a LinkedList and then incorporate it into the Serial monitor.
  2. We can implement the same functionality with an Array, however if you look at the commit history of commandHistory.java the codebase has moved from an initial Array implementation to the LinkedList version for performance reasons.

Looking forward to comments on how to proceed with this.

@per1234 per1234 changed the title Serial Backlog Serial Monitor message history Sep 13, 2022
@per1234 per1234 added the conclusion: resolved Issue was resolved label Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself topic: serial monitor Related to the Serial Monitor type: enhancement Proposed improvement
Projects
None yet
3 participants