Skip to content

Output view does not correctly handle carriage return #1473

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

Open
3 tasks done
per1234 opened this issue Sep 20, 2022 · 5 comments
Open
3 tasks done

Output view does not correctly handle carriage return #1473

per1234 opened this issue Sep 20, 2022 · 5 comments
Labels
topic: code Related to content of the project itself topic: theia Related to the Theia IDE framework type: imperfection Perceived defect in any part of project

Comments

@per1234
Copy link
Contributor

per1234 commented Sep 20, 2022

Describe the problem

Some command line tools generate an animated progress bar by using a carriage return without newline to repeatedly overwrite the same line.

🐛 This does not work when their output is printed in the "Output" view. The carriage return causes a line break to be added.

To reproduce

  1. Upload a sketch via the Arduino CLI command line interface to a board that uses an upload tool that produces an animated progress bar (e.g., Nano 33 BLE).
    🙂 There is a nice looking animated progress bar:
    cli3
  2. Do the same using Arduino IDE 1.8.19.
    🙂 There is a nice looking animated progress bar:
    ide-1 x
  3. Do the same using Arduino IDE 2.x
    🐛 The progress bar is not animated:
    ide-2 x

Expected behavior

The current line is overwritten from the start of the line in the "Output" view with subsequent text.

For example, this text:

foobar\rbaz

Should result in this content in the output view:

bazbar

Arduino IDE version

2.0.0-snapshot-4e590ab

Operating system

Windows, Ubuntu

Operating system version

Windows 10, Ubuntu 20.04

Additional context

Support was added in Arduino IDE 1.x by arduino/Arduino#9954


Originally reported at https://forum.arduino.cc/t/arduino-2-0-0-mac-ugh-why-so-backwards/1033549

Additional reports

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Sep 20, 2022
@cmaglie
Copy link
Member

cmaglie commented Sep 20, 2022

This is a problem in the console text area of the IDE becuase running arduino-cli from the command line shows the expected progress bar: this means that the standard-out stream from avrdude is correctly sent through gRPC.

We had this problem before in the Arduino IDE 1.8.x, it basically boils down to the text area not correctly handling the CR (Carriage Return) character:

CR and LF are control characters or bytecode that can be used to mark a line break in a text file.

CR = Carriage Return (\r, 0x0D in hexadecimal, 13 in decimal) — moves the cursor to the beginning of the line without advancing to the next line.
LF = Line Feed (\n, 0x0A in hexadecimal, 10 in decimal) — moves the cursor down to the next line without returning to the beginning of the line.

To render the progress bar, avrdude repeatedly overwrites the same line using CR as a control character to move the cursor back at the beginning of the line, without advancing to the next one. The issue here is that the IDE text area interprets CR as CR+LF moving the cursor to the next line.

IMHO this issue should be moved to the Arduino IDE repo.

@cmaglie
Copy link
Member

cmaglie commented Sep 20, 2022

Another question is: isn't the "console" text area already supporting some terminal control standard?

If we must implement all control characters from an ANSI terminal it will become a project on its own... maybe there is already an implementation of a "terminal" or a "console" text area that support ANSI (or vt100 or any other terminal standard) that can be reused.

@per1234 per1234 changed the title gRPC output does not support animated progress bars Output panel does not correctly handle carriage return Sep 20, 2022
@per1234 per1234 changed the title Output panel does not correctly handle carriage return Output view does not correctly handle carriage return Sep 20, 2022
@per1234 per1234 transferred this issue from arduino/arduino-cli Sep 20, 2022
@per1234
Copy link
Contributor Author

per1234 commented Sep 20, 2022

Thank @cmaglie. I didn't interpret the gRPC response content correctly. You are correct that Arduino CLI is handling it correctly and this is a bug in Arduino IDE. I have updated the issue and transferred it to the correct repo.

@kittaakos
Copy link
Contributor

The Output view is an editor and not a terminal. If we want terminal behavior, we must use a Pseudoterminal from VS Code. This change requires a bigger effort on the IDE2 side.

@kittaakos kittaakos self-assigned this Sep 21, 2022
@kittaakos kittaakos added the topic: theia Related to the Theia IDE framework label Sep 21, 2022
@kittaakos kittaakos removed their assignment Feb 23, 2024
@NoSloppy

This comment has been minimized.

@arduino arduino locked and limited conversation to collaborators Feb 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic: code Related to content of the project itself topic: theia Related to the Theia IDE framework type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

4 participants