Skip to content

Disable line-wrap when output is being redirected #1782

Description

@ap0llo

(Please correct me if this already exists)

Is your feature request related to a problem? Please describe.
In my application, we use Spectre.Console for all outputs and logging.
The output is often time longer than 80 characters which works fine for most users since their console is usually wide enough and Spectre.Console uses the current width.

However, when the output is being redirected to a file, the width defaults to 80 which causes lots of line-breaks to be inserted.
In this use case, it would be preferrable to not wrap any lines in case that the output is being redirected.

Describe the solution you'd like
It would be really useful to have an option to disable line wrapping for a specific IAnsiConsole.
I would enable this option when I detect that the output is being redirected.

Describe alternatives you've considered

As a workaround, I'm setting the width to a value > 80 in case the output is being redirected. However, this has some downsides

  • Widgets like Table will take up the full width of the terminal, so I cannot set the width arbitrarily high
  • Lines longer than the width will still be wrapped

I guess the way to really diable all wrapping would be setting the Width to int.MaxValue but that would result in really wide tables.


Please upvote 👍 this issue if you are interested in it.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions