Files
spectre.console/src/Spectre.Console/Internal/ConsoleHelper.cs
Patrik Svensson a23bec4082 Add profile support
Closes #231
2021-01-19 17:53:03 +01:00

44 lines
1004 B
C#

using System.IO;
namespace Spectre.Console
{
internal static class ConsoleHelper
{
public static int GetSafeWidth(int defaultValue = Constants.DefaultTerminalWidth)
{
try
{
var width = System.Console.BufferWidth;
if (width == 0)
{
width = defaultValue;
}
return width;
}
catch (IOException)
{
return defaultValue;
}
}
public static int GetSafeHeight(int defaultValue = Constants.DefaultTerminalHeight)
{
try
{
var height = System.Console.WindowHeight;
if (height == 0)
{
height = defaultValue;
}
return height;
}
catch (IOException)
{
return defaultValue;
}
}
}
}