[WIP] feat: Add a copy button to serial monitor #2718
+57
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
When collecting data with the Arduino, a straight-forward way to retrieve it is to write it to the serial monitor (often in csv format or similar) and store it somewhere.
As addressed in various issues (#1081, #2093, #812), retrieving this data from the serial monitor is hard to impossible currently, as it does not really support copying, nor has the functionality to write the data to a file.
Change description
This pull request introduces a button that copies the content of the serial monitor to the clipboard. It uses the raw data stored in the frontend (an array of strings/lines) and joins it to a single string that is copied. This avoids the issue of formatted text completely (#2093) and makes it easy to copy the full content (#1081, #812).
Other information
In the long run (and in order to fully resolve the issues above), a proper copy mechanism of the current selection should be implemented. But this seems to be hard, some related issue (#105) is almost five years old and still open, although there was some implementation effort.
This pull requests aim is to provide some small quality of life feature. It might be replaced by some farther reaching change in the future, or might even stay as it is useful as a quick action nonetheless.
Feedback needed
I created this pull request because I want to use the feature myself. I do not really understand the code structure and style conventions of this repository (Is there some style guide document? I could not find it), so I need feedback on these aspects.
The code itself is working as I would want to use it, allowing to copy the content of the serial monitor to the clipboard. There is a test for the method that joins the lines, I am not sure if the GUI components require tests.
Reviewer checklist