Skip to content
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

[REQUEST] Backspace and Carriage Return support #3260

Open
fullfox opened this issue Jan 16, 2024 · 1 comment
Open

[REQUEST] Backspace and Carriage Return support #3260

fullfox opened this issue Jan 16, 2024 · 1 comment

Comments

@fullfox
Copy link

fullfox commented Jan 16, 2024

How would you improve Rich?

Adding support for \r and \b, such as

from rich import text
text.Text("aaa\bx\ry") # would give <text 'yax' []>

Once ANSI control characters are removed from the plain text, this can easily be achieved in the Text() class constructor by overwriting the last character of the current line when encountering \b, and starting overwriting characters from the beginning of the line when encountering \r.

What problem does it solve for you?

This would significantly improve the ability for the Text.from_ansi() method to parse bash command outputs.

Note

To do this, \r and \b should be removed from the STRIP_CONTROL_CODES list and few lines from ansi.py should be modified.

I wanted to create a pull request, but I'm uncertain if integrating this functionality into the Text() constructor is an appropriate approach. I would appreciate guidance on where to implement this feature and what aspects should remain unaltered to ensure compatibility.

Copy link

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant