douglasg14b / BetterConsoleTables

Faster, colorable, more configurable, and more robust console colors & tables for C# console applications
GNU Lesser General Public License v3.0
92 stars 16 forks source link

Address issue setting Console.WindowWidth using dotnetcore on a mac #1

Closed brianmwhite closed 6 years ago

brianmwhite commented 6 years ago

I added logic in the PadRow method to check if the runtime is windows before attempting to set the Console.WindowWidth property. Before this change, an exception would be thrown if the console width was less than the row's length. I only tested this on a Mac.

Unhandled Exception: System.PlatformNotSupportedException: Operation is not supported on this platform.
   at System.ConsolePal.set_WindowWidth(Int32 value)
   at System.Console.set_WindowWidth(Int32 value)
   at BetterConsoleTables.Table.PadRow(String row)
douglasg14b commented 6 years ago

@brianmwhite Thanks, good catch. Looks like this also affects Linux, wonder if there is a different way to expand that on both...

brianmwhite commented 6 years ago

Maybe. This line sets a terminal window (taken from Can a Terminal window be resized with a Terminal command?) to 100x50 characters:

printf '\e[8;50;100t'

You could also keep an eye on this code in the dotnet corefx > ConsolePal.Unix.cs class to see if someone comes up with a cross platform way to handle it.