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]Preserve tabs #271

Closed
pwwang opened this issue Sep 7, 2020 · 4 comments
Closed

[REQUEST]Preserve tabs #271

pwwang opened this issue Sep 7, 2020 · 4 comments

Comments

@pwwang
Copy link

pwwang commented Sep 7, 2020

Have you checked the issues for a similar suggestions?
Yes

How would you improve Rich?
In the cases that tabs are desired to be preserved.

Give as much detail as you can. Example code of how you would like it to work would help.

from rich.console import Console
Console.print('a\tb')
# prints 'a{tab}b', instead of 'a        b'

What problem does it solved for you?
The case I encountered is that \t is used as a delimiter in -a value fish shell's complete command to separate a completion name and description. I want to use rich to print all possible combinations of completion names and descriptions like such:

install\tInstall a package
list\tList all installed packages
show\tShow info of given package

However, rich prints it with the tabs being replaced with spaces, which make complete command not recognize the descriptions.

What problem do you have that this feature would solve? I may be able to suggest an existing way of solving it.

Maybe set tab_size to 0 to preserve tabs?

@willmcgugan
Copy link
Collaborator

Do you need to use Rich for this case? Much of what Rich does re formatting and styling makes the output good for humans, but hard to consume by other programs.

You could write to the stream directly, and bypass Rich's processing with the following:

console.file.write("a\tb")

@pwwang
Copy link
Author

pwwang commented Sep 9, 2020

Just because I want to use some of the layouts of Rich. For example, Columns to align those completion candidates.

@willmcgugan
Copy link
Collaborator

But would writing to the file directly (with console.file.write) address your needs? Preserving tabs would pretty much break most of Rich's formatting.

@pwwang
Copy link
Author

pwwang commented Sep 10, 2020

Understood. Then I would rather use raw printing in such a case.

Closing this.
Thank you!

@pwwang pwwang closed this as completed Sep 10, 2020
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

2 participants