Files
spectre.console/src/Spectre.Console/Internal/ConsoleHelper.cs
Patrik Svensson 52c1d9122b Add global usings (#668)
* Use global usings

* Fix namespace declarations for test projects
2021-12-23 16:50:31 +01:00

40 lines
843 B
C#

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;
}
}
}